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

Workflow Snippet Generator - Incorrect format for Input with Choice Parameter

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: core
    • Labels:
    • Environment:
    • Similar Issues:

      Description

      Snippet generator generates an array:

      input id: 'Cc2a7d4d888ad098e3ca0ed7599d887d', message: 'Which environment?', ok: 'Submit', parameters: [[$class: 'ChoiceParameterDefinition', choices: ['Red', 'Blue', 'Green'], description: '', name: 'env']]
      

      ChoiceParameterDefinition requires a delimited string.

      Workaround by modifying the snippet code by converting array to string with "\n" separator, e.g.:

      input id: 'Cc2a7d4d888ad098e3ca0ed7599d887d', message: 'Which environment?', ok: 'Submit', parameters: [[$class: 'ChoiceParameterDefinition', choices: 'Red\nBlue\nGreen', description: '', name: 'env']]
      
      

      Or just join the Array elements:

      input id: 'Cc2a7d4d888ad098e3ca0ed7599d887d', message: 'Which environment?', ok: 'Submit', parameters: [[$class: 'ChoiceParameterDefinition', choices: ['Red', 'Blue', 'Green'].join('\n'), description: '', name: 'env']]
      

        Attachments

          Issue Links

            Activity

            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Daniel Beck
            Path:
            core/src/main/java/hudson/model/ChoiceParameterDefinition.java
            http://jenkins-ci.org/commit/jenkins/6de571632c3873689981c27902ae8269fdf094eb
            Log:
            Merge pull request #3014 from daniel-beck/JENKINS-26143

            JENKINS-26143 Make choice parameter work with choices list in pipeline

            Compare: https://github.com/jenkinsci/jenkins/compare/bb8913759634...6de571632c38

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Beck Path: core/src/main/java/hudson/model/ChoiceParameterDefinition.java http://jenkins-ci.org/commit/jenkins/6de571632c3873689981c27902ae8269fdf094eb Log: Merge pull request #3014 from daniel-beck/ JENKINS-26143 JENKINS-26143 Make choice parameter work with choices list in pipeline Compare: https://github.com/jenkinsci/jenkins/compare/bb8913759634...6de571632c38
            Hide
            danielbeck Daniel Beck added a comment -

            Merged, I expect this will be in Jenkins 2.112.

            Show
            danielbeck Daniel Beck added a comment - Merged, I expect this will be in Jenkins 2.112.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Daniel Beck
            Path:
            content/_data/changelogs/weekly.yml
            http://jenkins-ci.org/commit/jenkins.io/ad2121fb5435ee0aad0f5553f606dc8eba565b93
            Log:
            Note JENKINS-26143 in 2.112 changelog

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Beck Path: content/_data/changelogs/weekly.yml http://jenkins-ci.org/commit/jenkins.io/ad2121fb5435ee0aad0f5553f606dc8eba565b93 Log: Note JENKINS-26143 in 2.112 changelog
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Daniel Beck
            Path:
            content/_data/changelogs/weekly.yml
            http://jenkins-ci.org/commit/jenkins.io/df8a94b349fd051657d51f43d2b3d3c43ce1355a
            Log:
            Merge pull request #1455 from daniel-beck/changelog-2.112-JENKINS-26143

            Note JENKINS-26143 in 2.112 changelog

            Compare: https://github.com/jenkins-infra/jenkins.io/compare/5f085d28cebf...df8a94b349fd

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Beck Path: content/_data/changelogs/weekly.yml http://jenkins-ci.org/commit/jenkins.io/df8a94b349fd051657d51f43d2b3d3c43ce1355a Log: Merge pull request #1455 from daniel-beck/changelog-2.112- JENKINS-26143 Note JENKINS-26143 in 2.112 changelog Compare: https://github.com/jenkins-infra/jenkins.io/compare/5f085d28cebf...df8a94b349fd
            Hide
            hong yan-hong wang added a comment -

            Hello all,

            Since I upgraded Jenkins from jenkins:2.107.3-alpine to jenkins:2.121.1-alpine.

            And I found the dsl with choices have parse error happen when Jenkins start up.

            -------------------------------------------------------------------

                pipelineJob( "$app" ) {

                    properties {
                        nextBuildNumber( "$num".toInteger() )
                        parameters {
                            parameterDefinitions {
                                choiceParam {
                                    name( "$branchName" )
                                    choices( "$branchChoices" )
                                    description( '' )
                                }
                            }
                        }
                    }

                }

            -------------------------------------------------------------------

            I tried to realize the choices syntax of DSL in http://192.168.99.100:30808/plugin/job-dsl/api-viewer/index.html.

            I found the reference of choices expanded to recursive structure...

            What's going on with this function now?

            Thanks very much.

             

            BR

            Hong

            Show
            hong yan-hong wang added a comment - Hello all, Since I upgraded Jenkins from jenkins:2.107.3-alpine to jenkins:2.121.1-alpine. And I found the dsl with choices have parse error happen when Jenkins start up. -------------------------------------------------------------------     pipelineJob( "$app" ) {         properties {             nextBuildNumber( "$num".toInteger() )             parameters {                 parameterDefinitions {                     choiceParam {                         name( "$branchName" )                         choices ( "$branchChoices" )                         description( '' )                     }                 }             }         }     } ------------------------------------------------------------------- I tried to realize the choices syntax of DSL in http://192.168.99.100:30808/plugin/job-dsl/api-viewer/index.html. I found the reference of choices expanded to recursive structure... What's going on with this function now? Thanks very much.   BR Hong

              People

              • Assignee:
                danielbeck Daniel Beck
                Reporter:
                nharniman Nigel Harniman
              • Votes:
                38 Vote for this issue
                Watchers:
                44 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: