How to set git credentials using credentials option

I am writing job-dsl seed work. The seed task should be able to generate either from github.com or from my corporate github servers. I would like to keep one job, not two.

In each case, I would like jenkins to be authenticated. To do this, I hard-coded creds into a script. However, I am not happy with this. I would prefer to add the Credentials parameter to the seed job.

The problem is that the Creds parameter adds en ENV variable to the script that contains USERID / PASSWORD. http://steve-jansen.imtqy.com/blog/2014/12/16/parsing-jenkins-secrets-in-a-shell-script/

However, git jobdsl requires a credential identifier, not USERID / PASSWORD.

How to resolve this deadlock?

scm {
    git {
        remote {
            name('origin')
                url(repo)
                credentials(myCredential)
        }
        branch('master')
    }
}
+4
3

, Job DSL , wiki .

, , :

// use the github-ci-key credentials for authentication with GitHub 
job('example-1') { 
    scm { 
        git { 
            remote { 
                github('account/repo', 'ssh') 
                credentials('github-ci-key') 
            } 
        } 
    } 
} 

// assign the jarsign-keystore credentials to the PASSWORD build variable job('example-2') { 
    wrappers { 
        credentialsBinding { 
            usernamePassword('PASSWORD', 'jarsign-keystore') 
        } 
    } 
}
+1

, Duane , CredentialID , Jenkins. , .

Jenkins Credentials

, , -dsl script, .

.

+1

, . CredentialsPlugin 1.7 .

0
source

All Articles