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

This issue is archived. You can view it, but you can't modify it. Learn more

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

            Assignee:
            Andrew Bayer
            Reporter:
            Keith Zantow
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: