Saikat
Saikat

Reputation: 16710

Jenkins error while setting build parameters from Jenkinsfile

I am trying to set build parameter (String and password param) from the Jenkinsfile but I am getting following error and the build fails.

Caused by: java.lang.UnsupportedOperationException: PasswordParameterDefinition as a class hudson.model.ParameterDefinition could mean either hudson.model.PasswordParameterDefinition or com.michelin.cio.hudson.plugins.passwordparam.PasswordParameterDefinition
    at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(DescribableModel.java:419)

Upvotes: 2

Views: 4045

Answers (2)

Fernando Abad
Fernando Abad

Reputation: 21

If you are calling your class as:

[$class: 'PasswordParameterDefinition', defaultValue: '', description: 'Vpn password', name: 'Psw']

try with this:

[$class: 'hudson.model.PasswordParameterDefinition', defaultValue: '', description: 'Vpn password', name: 'Psw']

Upvotes: 2

Ken
Ken

Reputation: 1985

Copy/pasted from https://issues.jenkins-ci.org/browse/JENKINS-18141:

In the example above, the DSL tries to find a subclass of hudson.model.ParameterDefinition named PasswordParameterDefinition. In your installation there are two classes named PasswordParameterDefinition, one defined by Jenkins itself and one provided by the Mask Passwords Plugin. The DSL can't decide which to use, so it generates the error. If you have installed the Mask Passwords Plugin, you can use nonStoredPasswordParam to create a password parameter: https://jenkinsci.github.io/job-dsl-plugin/#path/job-parameters-nonStoredPasswordParam

Upvotes: 2

Related Questions