nexusUser and nexusPassword

85 views
Skip to first unread message

Sunil Mathew

unread,
Jan 20, 2023, 3:37:38 PM1/20/23
to jenkins...@googlegroups.com
Hi,

Here is my build.gradle:

repositories {
mavenLocal()
mavenCentral()
// nexus credentials (nexusUser and nexusPassword) are stored in ~/.gradle/gradle.properties
maven {
url "${nexusRepoUrl}/repository/maven-public/"
credentials {
username = nexusUser
password = nexusPassword
}
}
}

How can I provide nexusUser and nexusPassword to the job (ideally globally)?

Regards, Sunil

Martin Schmude

unread,
Jan 21, 2023, 1:54:14 PM1/21/23
to Jenkins Users
You should make use of the Jenkins credentials store.
Several kinds of secrets can be stored there. Type "User and password" suits your needs.

How to use that in your pipeline script:

opay...@chsc.de

unread,
Jan 22, 2023, 12:27:11 AM1/22/23
to Jenkins Users
Hi,

if you use nexusUser and nexusPassword in build.gradle like that, you can (ab)use environment variables to inject the credentials from Jenkins to Gradle as project properties (which you can access the same way as gradle properties).

https://docs.gradle.org/current/userguide/build_environment.html#sec:project_properties

> If the environment variable name looks like ORG_GRADLE_PROJECT_prop=somevalue, then Gradle will set a prop property on your project object, with the value of somevalue.

Note _prop is case-sensitive, i.e. it would be ORG_GRADLE_PROJECT_nexusUser, *not* _NEXUSUSER.

https://plugins.jenkins.io/credentials-binding/ (should be installed by default)
https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-secure-guide/injecting-secrets (cloudbees is the company behind jenkins)

BR
Reply all
Reply to author
Forward
0 new messages