alexvasilkov / GradleGitDependenciesPlugin

Gradle plugin to add external git repos as project dependencies
Apache License 2.0
105 stars 15 forks source link

[Question] How to use Github Credentials #10

Closed swapnil-kotwal-sp closed 4 years ago

swapnil-kotwal-sp commented 4 years ago

I read the README but it still unclear how can I use the Environment variables.

git {
    fetch 'https://example.com/repository.git', {
        dir "$rootDir/gradle/scripts"
        tag 'v1.2.3'
        username "$System.env.GIT_GITHUB_USERNAME"
        password "$System.env.GIT_GITHUB_PASSWORD"
    }
}

Is it right approach, as by default it doesn't pick-up the environment variable credentials ? Can you please help me what am I missing here?

alexvasilkov commented 4 years ago

Looks like your groovy code to get environment variables is not correct. First of all if you have a complex expression you need to use curly brakets in your string interpolation: "${System.env.GIT_GITHUB_USERNAME}". Though I don't think you need to use string interpolation at all here.

My another concern is with the way you are accessing env variable. I think it should be something like this instead: System.getenv()['GIT_GITHUB_USERNAME'].

Also note that you can just use authGroup parameter in this case, like this: authGroup 'github'. This way the plugin will automatically look for GIT_GITHUB_USERNAME and GIT_GITHUB_PASSWORD env variables.

swapnil-kotwal-sp commented 4 years ago

Perfect!!!, I was looking for authGroup 'github'

My initial impression was, this plugin will automatically read the ENV variables directly, i.e without authGroup e.g. GIT_GITHUB_USERNAME

Thanks for the help 🙏🏻