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

Non-identifier characters in parallel names unquoted

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Converting JSON to Jenkinsfile where parallel branch names contain non-identifier characters, the Jenkinsfile is invalid, the names are not quoted.

      E.g. this JSON:

      {"pipeline":{"agent":{"isLiteral":true,"value":"any"},"stages":[{"name":"parallel","branches":[{"name":"parallel 1","steps":[{"name":"echo","arguments":[{"key":"message","value":{"isLiteral":true,"value":"1"}}]}]},{"name":"parallel 2","steps":[{"name":"echo","arguments":[{"key":"message","value":{"isLiteral":true,"value":"2"}}]}]}]}]}}
      

      Generates this invalid Jenkinsfile:

      pipeline {
        agent any
        
        stages {
          stage('parallel') {
            steps {
              parallel(
                parallel 1: {
                  echo(message: '1')
                  
                },
                parallel 2: {
                  echo(message: '2')
                  
                }
              )
            }
          }
          
        }
        
      }
      

      Sorry for the ugly formatting.

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -

            Yup, needed to quote at least parallel branch names that aren't valid identifiers in Groovy. I decided to just quote all of them on toGroovy() serialization, 'cos why not.

            PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/79

            Show
            abayer Andrew Bayer added a comment - Yup, needed to quote at least parallel branch names that aren't valid identifiers in Groovy. I decided to just quote all of them on toGroovy() serialization, 'cos why not. PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/79
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStage.java
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java
            pipeline-model-definition/src/test/resources/json/parallelPipelineWithSpaceInBranch.json
            pipeline-model-definition/src/test/resources/parallelPipelineWithSpaceInBranch.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/1f595c9f5e8b8628627e2fd17af8a7ce622249a7
            Log:
            [FIXED JENKINS-40580] Quote parallel branch names

            Decided to be defensive and always quote when converting, rather than
            trying to figure out when we could avoid quoting.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStage.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java pipeline-model-definition/src/test/resources/json/parallelPipelineWithSpaceInBranch.json pipeline-model-definition/src/test/resources/parallelPipelineWithSpaceInBranch.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/1f595c9f5e8b8628627e2fd17af8a7ce622249a7 Log: [FIXED JENKINS-40580] Quote parallel branch names Decided to be defensive and always quote when converting, rather than trying to figure out when we could avoid quoting.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStage.java
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java
            pipeline-model-definition/src/test/resources/json/parallelPipelineQuoteEscaping.json
            pipeline-model-definition/src/test/resources/json/parallelPipelineWithSpaceInBranch.json
            pipeline-model-definition/src/test/resources/parallelPipelineQuoteEscaping.groovy
            pipeline-model-definition/src/test/resources/parallelPipelineWithSpaceInBranch.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/fbfb5ab29fd98948569a82599d74d05a75f46f6d
            Log:
            Merge pull request #79 from abayer/jenkins-40580

            [FIXED JENKINS-40580] Quote parallel branch names

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStage.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java pipeline-model-definition/src/test/resources/json/parallelPipelineQuoteEscaping.json pipeline-model-definition/src/test/resources/json/parallelPipelineWithSpaceInBranch.json pipeline-model-definition/src/test/resources/parallelPipelineQuoteEscaping.groovy pipeline-model-definition/src/test/resources/parallelPipelineWithSpaceInBranch.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/fbfb5ab29fd98948569a82599d74d05a75f46f6d Log: Merge pull request #79 from abayer/jenkins-40580 [FIXED JENKINS-40580] Quote parallel branch names

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                kzantow Keith Zantow
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: