Environment

Article ID:360055603872
1 minute readKnowledge base

Issue

After Jenkins update to 2.249, trying to set a default value for the "password" parameter using DSL job shows the following error:

No such property: Secret for class: javaposse.jobdsl.plugin.structs.DescribableContext

Explanation

After Jenkins update to 2.249, the "password" parameter method to set the default value changed from defaultValue("foo") to defaultValueAsSecret(Secret.fromString("foo")) (as described in https://issues.jenkins.io/browse/JENKINS-63499) and Job DSL plugin doesn’t recognize the hudson.util.Secret class.

Example of the new method:

password{
   name('name')
   description('description')
   defaultValueAsSecret(Secret.fromString("foo"))
}

Resolution

This is being fixed in https://issues.jenkins.io/browse/JENKINS-64539. Consult if there is a fix in more recent versions. On the contrary, it won’t be possible to set a default value for a password using Jod DSL.

As a workaround, create a scripted pipeline for this purpose and avoid Job DSL for the moment.

Tested product/plugin versions

Job DSL Plugin version 1.77

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.