Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-67973

Job DSL plugin: passwordParam not available


      I'm using a DSL pipeline to create all my Jenkins jobs, from the job DSL plugin. Till now, when a password as parameter was required, I was using nonStoredPasswordParam from the "Mask Passwords" plugin.

      pipelineJob(path) {



      parameters {

          choiceParam(it.name, it.choices, it.description)

          stringParam(it.name, default_value, it.description)

          nonStoredPasswordParam(it.name, it.description) 



      Currently, one of my customer requires to be able to reuse its previous password (Rebuild or Replay from stage), even if the pipeline is recreated between the first build and the rebuild (bug correction). The only solution I found was to use the legacy passwordParam feature.
      Unfortunately, I found no way to used it (passwordParam) in a DSL script and get this error message: ERROR: (unknown source) No signature of method: javaposse.jobdsl.dsl.helpers.BuildParametersContext.passwordParam() is applicable for argument types: (java.lang.String, null, java.lang.String) values: [APPOWNERPWD, null, Password demo]

      Despite of this of error, I was able to create this kind of parameter using the direct declaration in the created pipeline or using a groovy:


      {     options  

      {  ...  }


      {       password(name: 'MY_PASSWD', defaultValue: 'default', description: 'My lovely password')    }

               environment { ... }

               agent { ... }

               stages { ... }


      path = "folder1/folder2/pipelineA"

      name = "MY_PASSWD"

      default_password = "default"

      description = "My lovely password"

      newParameters = []

      newParam = new hudson.model.PasswordParameterDefinition(name, default_password, description)

      Jenkins instance = Jenkins.getInstance()

      def job = Jenkins.instance.getItemByFullName(path)
      for (prop in job.getAllProperties()) {

          if ( prop instanceof hudson.model.ParametersDefinitionProperty ) {

              for (param in prop.parameterDefinitions) {

                   println("Taken Parameter: ${param.name}")




      // Resetting the job pipeline definitionjob.removeProperty(ParametersDefinitionProperty.class)

      job.addProperty(new ParametersDefinitionProperty(newParameters))



      Could you improve the DSL plugin to allow the usage of the hudson.model.PasswordParameterDefinition kind of parameter?


            jamietanna Jamie Tanna
            gbegin Gautier BEGIN
            1 Vote for this issue
            1 Start watching this issue