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

          bwijsmuller created issue -
          Jesse Glick made changes -
          Component/s Original: pipeline [ 21692 ]
          Jesse Glick made changes -
          Labels Original: cps pipeline switch New: cps switch
          Jesse Glick made changes -
          Epic Link New: JENKINS-35390 [ 171183 ]

          Jesse Glick added a comment -

          Try running inside @NonCPS.

          Jesse Glick added a comment - Try running inside @NonCPS .
          Andrew Bayer made changes -
          Assignee New: Andrew Bayer [ abayer ]
          Andrew Bayer made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Andrew Bayer made changes -
          Labels Original: cps switch New: complex-cps-code cps switch triaged-2018-11

          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).
          Andrew Bayer made changes -
          Assignee Original: Andrew Bayer [ abayer ]

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

              Created:
              Updated: