[JIRA] (JENKINS-41518) Environment variable names not checked for validity during JSON -> Jenkinsfile resulting in invalid syntax

0 views
Skip to first unread message

kzantow@cloudbees.com (JIRA)

unread,
Jan 27, 2017, 10:46:01 AM1/27/17
to jenkinsc...@googlegroups.com
Keith Zantow created an issue
 
Jenkins / Bug JENKINS-41518
Environment variable names not checked for validity during JSON -> Jenkinsfile resulting in invalid syntax
Issue Type: Bug Bug
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2017/Jan/27 3:45 PM
Priority: Minor Minor
Reporter: Keith Zantow

The environment variable name should be valid Java (well, Groovy) identifier, it should be validated such as not generating invalid Jenkinsfiles.

This JSON:

{
    "pipeline": {
        "agent": {
            "type": "none",
            "arguments": []
        },
        "stages": [
            {
                "name": "s",
                "branches": [
                    {
                        "name": "default",
                        "steps": [
                            {
                                "name": "echo",
                                "arguments": [
                                    {
                                        "key": "message",
                                        "value": {
                                            "isLiteral": true,
                                            "value": "m"
                                        }
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        ],
        "environment": [
            {
                "key": "S    PACE",
                "value": {
                    "isLiteral": true,
                    "value": ""
                }
            },
            {
                "key": "",
                "value": {
                    "isLiteral": true,
                    "value": ""
                }
            }
        ]
    }
}

Results in this invalid Jenkinsfile:

pipeline {
  agent none
  stages {
    stage('s') {
      steps {
        echo('m')
      }
    }
  }
  environment {
    S    PACE = ''
     = ''
  } 
}
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,
Jan 27, 2017, 10:54:01 AM1/27/17
to jenkinsc...@googlegroups.com
Andrew Bayer started work on Bug JENKINS-41518
 
Change By: Andrew Bayer
Status: Open In Progress

andrew.bayer@gmail.com (JIRA)

unread,
Jan 27, 2017, 10:55:42 AM1/27/17
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

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

andrew.bayer@gmail.com (JIRA)

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

andrew.bayer@gmail.com (JIRA)

unread,
Jan 27, 2017, 12:08:02 PM1/27/17
to jenkinsc...@googlegroups.com

scm_issue_link@java.net (JIRA)

unread,
Jan 27, 2017, 12:08:03 PM1/27/17
to jenkinsc...@googlegroups.com
SCM/JIRA link daemon commented on Bug JENKINS-41518
 
Re: Environment variable names not checked for validity during JSON -> Jenkinsfile resulting in invalid syntax

Code changed in jenkins
User: Andrew Bayer
Path:
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/Messages.properties
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BaseParserLoaderTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ErrorsJSONParserTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/JSONValidationTest.java
pipeline-model-definition/src/test/resources/json/errors/invalidIdentifierInEnv.json
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/e3d0a948f28975a595f41d0749907c788bfb0306
Log:
[FIXED JENKINS-41518] Validate env var names for validity

Specifically for validity as Java identifiers - otherwise everything
'splodes. This was never a problem from the Jenkinsfile side, since
there'd be compilation errors before getting to validation if you used
an invalid identifier, but it is a problem coming from JSON.

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:25:50 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