Reputation: 7141
I have a gradle project with configuration below
apply plugin: 'java'
apply plugin: 'maven'
repositories {
mavenCentral()
maven {
credentials {
username "$System.env.REPOSITORY_USER"
password "$System.env.REPOSITORY_PWD"
}
url "$System.env.REPOSITORY_HOME" + /nexus/content/groups/public/"
}
}
Ideally only the build server should know the repository username and password that has publish rights, everyone else should have read only access (the credentials block should not be applied). Is there a way I could conditionally add the credentials
block based on if both REPOSITORY_USER
and REPOSITORY_PWD
is populated?
I'm open to better solutions if you have any suggestions!
Upvotes: 3
Views: 1581
Reputation: 12986
Try to use something like this:
repositories {
mavenCentral()
}
if (System.env.REPOSITORY_USER != null && System.env.REPOSITORY_PWD != null) {
repositories {
maven {
// Setup here what you need
credentials {
}
}
}
}
Upvotes: 5