jenkinsci / jenkinsci/workflow-cps-plugin

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

Open
#1,301 3 comments 0 reactions 0 assignees View on GitHub
component:workflow-cps-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
186
Forks
213
Avg merge
12h 12m
Merged PRs (30d)
8

Description

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.

 

---
Originally reported by bwijsmuller, imported from: switch statement default case not called if other match found in Pipeline DSL


  • status: In Progress
  • priority: Minor
  • component(s): workflow-cps-plugin
  • label(s): complex-cps-code, cps, switch, triaged-2018-11
  • resolution: Unresolved
  • votes: 1
  • watchers: 4
  • imported: 2025-12-07

Raw content of original issue

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.

 

  • environment: redhat linux, jenkins 2.34, Pipeline 2.5

Contributor guide

Open the contributing guide

Research direction

Start with the Pipeline DSL switch statement entry point and run the minimal reproducer from the issue on the reported Jenkins and Pipeline versions. Trace how a matching case and the default case are handled, then add a regression test showing the expected output for both matching and nonmatching cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.