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

switch statement default case not called if other match found in Pipeline DSL

      The simplest of scripts to reproduce the issue:

      switch ("triggervalue") {
          case "triggervalue":
              echo "triggervalue match"
          default:
              echo "Sorry, this does not print..."
      }
      

      When no other case is triggered, then the default does seem to work.

       

          [JENKINS-43389] switch statement default case not called if other match found in Pipeline DSL

          Jesse Glick added a comment -

          Try running inside @NonCPS.

          Jesse Glick added a comment - Try running inside @NonCPS .

          William Brode added a comment -

          Can confirm this is still an issue on Jenkins 2.204.2 and workflow-cps 2.80 (assuming that is where the issue lies).

          William Brode added a comment - Can confirm this is still an issue on Jenkins 2.204.2 and workflow-cps 2.80 (assuming that is where the issue lies).

          Same issue here: https://issues.jenkins.io/browse/JENKINS-54652

          ("default:" behaves like "break; default:")

          Klaus Hegemann added a comment - Same issue here: https://issues.jenkins.io/browse/JENKINS-54652 ("default:" behaves like "break; default:")

            Unassigned Unassigned
            bwijsmuller bwijsmuller
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: