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

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

    Details

    • Similar Issues:

      Description

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

        Attachments

          Issue Links

            Activity

              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: