[JIRA] (JENKINS-41503) JSON Schema issue: mapArgumentValue not accepting null

3 views
Skip to first unread message

kzantow@cloudbees.com (JIRA)

unread,
Jan 26, 2017, 11:16:01 PM1/26/17
to jenkinsc...@googlegroups.com
Keith Zantow created an issue
 
Jenkins / Bug JENKINS-41503
JSON Schema issue: mapArgumentValue not accepting null
Issue Type: Bug Bug
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2017/Jan/27 4:15 AM
Priority: Minor Minor
Reporter: Keith Zantow

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

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\""
                                        }
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
    }
}
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

kzantow@cloudbees.com (JIRA)

unread,
Jan 26, 2017, 11:16:01 PM1/26/17
to jenkinsc...@googlegroups.com
Keith Zantow updated an issue
Change By: Keith Zantow
Arguments with _ { isLiteral: true, "value": null } _
fail schema validation.
{code}

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"'
            }
        }
    }
}
{code}


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

{code}
{code}

kzantow@cloudbees.com (JIRA)

unread,
Jan 26, 2017, 11:17:01 PM1/26/17
to jenkinsc...@googlegroups.com
Keith Zantow updated an issue
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.

andrew.bayer@gmail.com (JIRA)

unread,
Feb 22, 2017, 4:41:02 PM2/22/17
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Feb 22, 2017, 4:41:02 PM2/22/17
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Feb 22, 2017, 4:41:02 PM2/22/17
to jenkinsc...@googlegroups.com
Andrew Bayer started work on Bug JENKINS-41503
 
Change By: Andrew Bayer
Status: Open In Progress

scm_issue_link@java.net (JIRA)

unread,
Feb 23, 2017, 3:02:04 PM2/23/17
to jenkinsc...@googlegroups.com
SCM/JIRA link daemon commented on Bug JENKINS-41503
 
Re: JSON Schema issue: mapArgumentValue not accepting null

Code changed in jenkins
User: Andrew Bayer
Path:
pipeline-model-api/src/main/resources/ast-schema.json
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/Converter.groovy
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
pipeline-model-definition/src/test/resources/json/jsonSchemaNull.json
pipeline-model-definition/src/test/resources/jsonSchemaNull.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/6e518e32c311d5f80458a1911cbbea6b4da87783
Log:
[FIXED JENKINS-41503] Allow null values in JSON

Also required changing org.json -> Jackson conversion to go through a
string rather than use a mapper due to the mapper not liking nulls at
all.

andrew.bayer@gmail.com (JIRA)

unread,
Feb 24, 2017, 1:32:05 PM2/24/17
to jenkinsc...@googlegroups.com

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:24:20 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