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

JSON Schema issue: mapArgumentValue not accepting null

XMLWordPrintable

      Arguments with

      { isLiteral: true, "value": null }

      fail schema validation.

      I think this needs to allow null values: https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/master/pipeline-model-api/src/main/resources/ast-schema.json#L50 or alternately, don't include those args in the JSON during conversion? Not sure if they are necessarily equivalent.

      Took this valid pipeline:

      pipeline {
          agent {
              docker {
                  image "httpd:2.4.12"
                  args null
              }
          }
          stages {
              stage("foo") {
                  steps {
                      sh 'cat /usr/local/apache2/conf/extra/httpd-userdir.conf'
                      sh 'echo "The answer is 42"'
                  }
              }
          }
      }
      

      which converts to the corresponding JSON, that no longer passes schema validation due to agent docker args null value:

      {
          "pipeline": {
              "agent": {
                  "type": "docker",
                  "arguments": [
                      {
                          "key": "image",
                          "value": {
                              "isLiteral": true,
                              "value": "httpd:2.4.12"
                          }
                      },
                      {
                          "key": "args",
                          "value": {
                              "isLiteral": true,
                              "value": null
                          }
                      }
                  ]
              },
              "stages": [
                  {
                      "name": "foo",
                      "branches": [
                          {
                              "name": "default",
                              "steps": [
                                  {
                                      "name": "sh",
                                      "arguments": [
                                          {
                                              "key": "script",
                                              "value": {
                                                  "isLiteral": true,
                                                  "value": "cat /usr/local/apache2/conf/extra/httpd-userdir.conf"
                                              }
                                          }
                                      ]
                                  },
                                  {
                                      "name": "sh",
                                      "arguments": [
                                          {
                                              "key": "script",
                                              "value": {
                                                  "isLiteral": true,
                                                  "value": "echo \"The answer is 42\""
                                              }
                                          }
                                      ]
                                  }
                              ]
                          }
                      ]
                  }
              ]
          }
      }
      

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

              Created:
              Updated:
              Resolved: