[JIRA] (JENKINS-40580) Non-identifier characters in parallel names unquoted

2 views
Skip to first unread message

kzantow@cloudbees.com (JIRA)

unread,
Dec 20, 2016, 3:33:01 PM12/20/16
to jenkinsc...@googlegroups.com
Keith Zantow created an issue
 
Jenkins / Bug JENKINS-40580
Non-identifier characters in parallel names unquoted
Issue Type: Bug Bug
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2016/Dec/20 8:32 PM
Priority: Major Major
Reporter: Keith Zantow

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.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

andrew.bayer@gmail.com (JIRA)

unread,
Dec 20, 2016, 3:51:12 PM12/20/16
to jenkinsc...@googlegroups.com
Andrew Bayer started work on Bug JENKINS-40580
 
Change By: Andrew Bayer
Status: Open In Progress

andrew.bayer@gmail.com (JIRA)

unread,
Dec 20, 2016, 3:52:01 PM12/20/16
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Dec 20, 2016, 3:53:01 PM12/20/16
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-40580
 
Re: Non-identifier characters in parallel names unquoted

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

scm_issue_link@java.net (JIRA)

unread,
Jan 5, 2017, 11:10:01 AM1/5/17
to jenkinsc...@googlegroups.com

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.

andrew.bayer@gmail.com (JIRA)

unread,
Jan 5, 2017, 11:11:02 AM1/5/17
to jenkinsc...@googlegroups.com

scm_issue_link@java.net (JIRA)

unread,
Jan 5, 2017, 11:17:01 AM1/5/17
to jenkinsc...@googlegroups.com

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

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:24:17 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Fixed
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages