job-dsl-gradle-example
job-dsl-gradle-example copied to clipboard
How to use hudson.util.Secret in the project?
I'm injecting passwords from my dsl job into the created job. However, I want to encrypt them with import hudson.util.Secret;
but i'm having the hardest time including the library without breaking the test. The groovy script works when executed in jenkins but depending on what version of the import hudson.util.Secret;
i use i'll get a range of errors.
I was wondering how do you go about using the library or if there is another way to encrypt the passwords injected into the job so they aren't visible from the
When I try to use the latest
compile 'org.eclipse.hudson:hudson-core:3.3.3'
to my gradle project with
repositories {
mavenCentral()
maven { url 'https://repo.jenkins-ci.org/releases/' }
jcenter()
}
I get the following error:
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not resolve org.eclipse.hudson:hudson-remoting:3.0.3.
Required by:
project : > org.eclipse.hudson:hudson-core:3.3.3
project : > org.eclipse.hudson:hudson-core:3.3.3 > org.eclipse.hudson:hudson-cli:3.3.3
> Could not resolve org.eclipse.hudson:hudson-remoting:3.0.3.
> inconsistent module metadata found. Descriptor: org.eclipse.hudson:hudson-remoting:3.0.4-SNAPSHOT Errors: bad version: expected='3.0.3' found='3.0.4-SNAPSHOT'
> Could not resolve org.eclipse.hudson:hudson-remoting:3.0.3.
> Could not get resource 'https://jcenter.bintray.com/org/eclipse/hudson/hudson-remoting/3.0.3/hudson-remoting-3.0.3.pom'.
> Could not HEAD 'https://jcenter.bintray.com/org/eclipse/hudson/hudson-remoting/3.0.3/hudson-remoting-3.0.3.pom'. Received status code 409 from server: Conflict
I've tried several other version as well, and in those cases I would get run time issue at the point when it's actually the secret.encrypt is actually being executed.
injectGlobalPasswords(false)
maskPasswordParameters(true)
passwordEntries() {
for (password in passwords.entrySet()) {
Secret secret = Secret.fromString(password.getValue())
'EnvInjectPasswordEntry' {
name(password.getKey())
value(secret.getEncryptedValue())
}
}
}
I'm trying to execute something like above which results in the issue.
Any advice appreciated thanks Derek