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

Trigger validation for unknown trigger types isn't working

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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. I also suspect this may be the same for properties and parameters.

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -

            PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/68. I feel sheepish about not catching this earlier.

            Show
            abayer Andrew Bayer added a comment - PR up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/68 . I feel sheepish about not catching this earlier.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            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.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - 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.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                abayer Andrew Bayer
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: