[JIRA] (JENKINS-40418) Trigger validation for unknown trigger types isn't working

4 views
Skip to first unread message

andrew.bayer@gmail.com (JIRA)

unread,
Dec 13, 2016, 12:48:03 PM12/13/16
to jenkinsc...@googlegroups.com
Andrew Bayer created an issue
 
Jenkins / Bug JENKINS-40418
Trigger validation for unknown trigger types isn't working
Issue Type: Bug Bug
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2016/Dec/13 5:47 PM
Priority: Minor Minor
Reporter: Andrew Bayer

With a pipeline like the below, we'd expect to get an error saying "hey, banana's not a trigger, here are the trigger types", but instead we get past parsing and validating and barf at runtime instead:

pipeline {
    agent none
    triggers {
        banana('@daily')
    }
    stages {
        stage("foo") {
            steps {
                echo "hello"
            }
        }
    }
}

Output:

First time build. Skipping changelog.
[Pipeline] End of Pipeline
java.lang.NoSuchMethodError: No such DSL method 'banana' found among steps [archive, bat, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, dockerLabel, echo, envVarsForTool, error, fileExists, getContext, git, input, isUnix, libraryResource, load, mail, node, parallel, properties, pwd, readFile, readTrusted, retry, script, semaphore, sh, sleep, stage, stash, step, timeout, tool, unarchive, unstash, waitUntil, withContext, withCredentials, withDockerContainer, withDockerRegistry, withDockerServer, withEnv, wrap, writeFile, ws] or symbols [all, always, any, apiToken, architecture, archiveArtifacts, artifactManager, batchFile, booleanParam, buildButton, buildDiscarder, caseInsensitive, caseSensitive, choice, choiceParam, clock, cloud, command, cron, crumb, defaultView, demand, disableConcurrentBuilds, docker, dockerfile, downloadSettings, downstream, dumb, envVars, file, fileParam, filePath, fingerprint, frameOptions, freeStyle, freeStyleJob, git, hyperlink, hyperlinkToModels, installSource, jdk, jdkInstaller, jgit, jnlp, jobName, label, lastDuration, lastFailure, lastGrantedAuthorities, lastStable, lastSuccess, legacy, list, local, location, logRotator, loggedInUsersCanDoAnything, masterBuild, maven, maven3Mojos, mavenErrors, mavenMojos, mavenWarnings, myView, nodeProperties, nonStoredPasswordParam, none, otherField, overrideIndexTriggers, paneStatus, parameters, password, pattern, pipeline-model, pipelineTriggers, plainText, plugin, projectNamingStrategy, proxy, queueItemAuthenticator, quietPeriod, run, runParam, schedule, scm, scmRetryCount, search, security, shell, slave, stackTrace, standard, status, string, stringParam, swapSpace, text, textParam, tmpSpace, toolLocation, unsecured, upstream, viewsTabBar, weather, zfs, zip] or globals [currentBuild, docker, env, params, pipeline, scm]

We should be failing out at validation time, not runtime.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

andrew.bayer@gmail.com (JIRA)

unread,
Dec 13, 2016, 12:48:03 PM12/13/16
to jenkinsc...@googlegroups.com
Andrew Bayer updated an issue
Change By: Andrew Bayer
With a pipeline like the below, we'd expect to get an error saying "hey, banana's not a trigger, here are the trigger types", but instead we get past parsing and validating and barf at runtime instead:

{code}

pipeline {
    agent none
    triggers {
        banana('@daily')
    }
    stages {
        stage("foo") {
            steps {
                echo "hello"
            }
        }
    }
}
{code}

Output:
{code}

First time build. Skipping changelog.
[Pipeline] End of Pipeline
java.lang.NoSuchMethodError: No such DSL method 'banana' found among steps [archive, bat, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, dockerLabel, echo, envVarsForTool, error, fileExists, getContext, git, input, isUnix, libraryResource, load, mail, node, parallel, properties, pwd, readFile, readTrusted, retry, script, semaphore, sh, sleep, stage, stash, step, timeout, tool, unarchive, unstash, waitUntil, withContext, withCredentials, withDockerContainer, withDockerRegistry, withDockerServer, withEnv, wrap, writeFile, ws] or symbols [all, always, any, apiToken, architecture, archiveArtifacts, artifactManager, batchFile, booleanParam, buildButton, buildDiscarder, caseInsensitive, caseSensitive, choice, choiceParam, clock, cloud, command, cron, crumb, defaultView, demand, disableConcurrentBuilds, docker, dockerfile, downloadSettings, downstream, dumb, envVars, file, fileParam, filePath, fingerprint, frameOptions, freeStyle, freeStyleJob, git, hyperlink, hyperlinkToModels, installSource, jdk, jdkInstaller, jgit, jnlp, jobName, label, lastDuration, lastFailure, lastGrantedAuthorities, lastStable, lastSuccess, legacy, list, local, location, logRotator, loggedInUsersCanDoAnything, masterBuild, maven, maven3Mojos, mavenErrors, mavenMojos, mavenWarnings, myView, nodeProperties, nonStoredPasswordParam, none, otherField, overrideIndexTriggers, paneStatus, parameters, password, pattern, pipeline-model, pipelineTriggers, plainText, plugin, projectNamingStrategy, proxy, queueItemAuthenticator, quietPeriod, run, runParam, schedule, scm, scmRetryCount, search, security, shell, slave, stackTrace, standard, status, string, stringParam, swapSpace, text, textParam, tmpSpace, toolLocation, unsecured, upstream, viewsTabBar, weather, zfs, zip] or globals [currentBuild, docker, env, params, pipeline, scm]
{code}

We should be failing out at validation time, not runtime.
I also suspect this may be the same for {{properties}} and {{parameters}}.

andrew.bayer@gmail.com (JIRA)

unread,
Dec 13, 2016, 12:50:05 PM12/13/16
to jenkinsc...@googlegroups.com
Andrew Bayer started work on Bug JENKINS-40418
 
Change By: Andrew Bayer
Status: Open In Progress

andrew.bayer@gmail.com (JIRA)

unread,
Dec 13, 2016, 1:17:02 PM12/13/16
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Dec 13, 2016, 1:17:02 PM12/13/16
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Dec 14, 2016, 1:15:01 PM12/14/16
to jenkinsc...@googlegroups.com

scm_issue_link@java.net (JIRA)

unread,
Dec 16, 2016, 1:30:02 PM12/16/16
to jenkinsc...@googlegroups.com
SCM/JIRA link daemon commented on Bug JENKINS-40418
 
Re: Trigger validation for unknown trigger types isn't working

Code changed in jenkins
User: Andrew Bayer
Path:
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTBuildParameter.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTJobProperty.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTScriptBlock.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTTrigger.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWrapper.java
pipeline-model-api/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorTest.java
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
pipeline-model-definition/src/test/resources/errors/invalidParameterType.groovy
pipeline-model-definition/src/test/resources/errors/invalidPropertiesType.groovy
pipeline-model-definition/src/test/resources/errors/invalidTriggerType.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/6bfbffd5260ed4f219cba21cdba809b205390e82
Log:
[FIXED JENKINS-40418] Fix validation for a number of extended types

Turns out we do need validate methods on child classes - the parent
validate method will end up calling
validator.validateElement(ParentClass) which is...not what we
want. So, fixing that in a bunch of places and adding tests.

Also, added an expectError convenience method.

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:25:39 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