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

Closures in strings result in silently skipped declarative steps

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: pipeline
    • Labels:
      None
    • Similar Issues:

      Description

      Using closures in a declarative step skips the step without any message.

      I would expect the closures to work, but at least an error would be nice.

      Steps to reproduce

      1. Create Pipeline project
      2. Paste pipeline script
        def wrapme = {String s -> "-- ${s} --"}
        def wrappedString = "${ -> wrapme('as var')}"
        def plainString = "string"
        
        pipeline {
            agent any
            stages {
                stage('Demo') {
                    steps {
                        // This works
                        echo wrapme('explicit')
                        // This is skipped
                        echo "Closure: ${ -> wrapme('implicit')}"
                        // so is this
                        echo wrappedString
                        // and this
                        echo "String: ${ -> plainString}"
                        // And this line at least gives an error
                        //echo "As string: ${wrappedString}"
                    }
                }
            }
        }
        
      1. Build
        The output is
        [Pipeline] {
        [Pipeline] stage
        [Pipeline] { (Demo)
        [Pipeline] echo
        -- explicit --
        [Pipeline] }
        [Pipeline] // stage
        [Pipeline] }
        [Pipeline] // node
        [Pipeline] End of Pipeline
        

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              yoerg Joerg H
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: