-
Bug
-
Resolution: Fixed
-
Major
-
None
-
Jenkins 1.609.2, Job DSL 1.35, Credentials 1.22, Credentials Binding 1.4, Cloudbees Folder 4.9
I am running into a problem where credentials defined in my job are somehow eaten by the DSL without being inserted into the generated jobs. I can't seem to pin down if this is triggered by something or not. I've seen it in two completely separate Jenkins environments though; on one it was only showing up if I attempted to bind multiple credentials (the 2nd and greater ones failed), on the other it fails with every credential.
Here is a DSL that illustrates the problem on my system:
def jobs = [ 'job1': 'data1', 'job2': 'data2', 'job3': 'data3', ]; println "Deployment credential: " + DEPLOYMENT_CREDENTIAL jobs.each { k, v -> def jobName = "${k}.${BaseVersion}"; freeStyleJob("${jobName}") { parameters { stringParam('VERSION'); } wrappers { preBuildCleanup(); buildName('${ENV,var="VERSION"}'); credentialsBinding { usernamePassword('DEPLOY_USER', 'DEPLOY_PASS', DEPLOYMENT_CREDENTIAL); } } } }
This was driven by a freestyle job with 2 parameters: a string parameter BaseVersion and a credentials parameter DEPLOYMENT_CREDENTIAL. The job succeeds and the ID is actually printed in the job log as expected, but the ID is missing from the generated job XML:
<org.jenkinsci.plugins.credentialsbinding.impl.SecretBuildWrapper> <bindings> <org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordMultiBinding> <credentialsId>null</credentialsId> <usernameVariable>DEPLOY_USER</usernameVariable> <passwordVariable>DEPLOY_PASS</passwordVariable> </org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordMultiBinding> </bindings> </org.jenkinsci.plugins.credentialsbinding.impl.SecretBuildWrapper>
Of course this breaks the generated jobs. I have to go set the credential manually in each one.