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

switch expression compile error

XMLWordPrintable

      A switch expression like this in a groovy DSL pipeline code.

      javaVersion = switch (jdkVersion) {
      case "JDK8", null -> "OpenJDK 8"
      case "JDK11" -> "OpenJDK 11"
      case "JDK17" -> "OpenJDK 17"
      {{default -> { error("The JDK version ${jdkVersion} is unknown. Expected JDK8 (default), JDK11 or JDK17."); "" }}}
      }

      produces a compile error similar to this.
      WorkflowScript: 96: unexpected token: switch @ line 96, column 29.

       

      Jenkins 2.375.1

            Unassigned Unassigned
            gajatko Jacek
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: