Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use hudson.util.Secret in the project? #114

Open
darewreck54 opened this issue Mar 2, 2022 · 0 comments
Open

How to use hudson.util.Secret in the project? #114

darewreck54 opened this issue Mar 2, 2022 · 0 comments

Comments

@darewreck54
Copy link

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 /config.xml file

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant