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

Closures in strings result in silently skipped declarative steps

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • pipeline
    • None

      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
        

            Unassigned Unassigned
            yoerg Yoerg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: