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

Environment variable names not checked for validity during JSON -> Jenkinsfile resulting in invalid syntax

XMLWordPrintable

      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 = ''
           = ''
        } 
      }
      

            abayer Andrew Bayer
            kzantow Keith Zantow
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: