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

Improved parameter checking and error checking in Jenkinsfiles

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • pipeline
    • None

      When doing a bad entry for the label parameter the respective error seems to pop up very late in the process - with tons of backtrace lines (>100 maybe?). And the error can move around with other codes, e.g. when having a call to cleanWS() its somewhere there in the pipeline, but when that statement is not there, the error happens even somewhere outside the scripting. Thus an error at the end of the operation is non good, when the error itself is close to the very top of the pipeline codes.

      Further aspect - the selection of the agent seemed to be sort of random and not to fail at all or maybe it worked most of the time - not totally sure with that.

      Code snippet example (bad):

      pipeline{
      agent {
      label 'A' && 'B'

      Code snippet example (good):

      pipeline{
      agent {
      label 'A && B'

      the bad example sometimes will raise those error:
      java.lang.ClassCastException: org.jenkinsci.plugins.pipeline.modeldefinition.agent.impl.Label.label expects class java.lang.String but received class java.lang.Boolean

      The "bad" code is definitely bad as it uses a pair of strings being joined by the and-operator into a boolean. But the error message reporting the system performs is coming a) far to late because 99% of the whole pipeline had already executed (and maybe on the wrong build node?!?) and b) in a style that makes it hard to find the culprit line. (just "label".... - i had this keyword a hundred times in the codes so no good guess unless there is a line number of where the parameter exactly comes from.)

            Unassigned Unassigned
            alexanderstohr_li Alexander
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: