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

preserveStashes does not work with parameter

    Details

    • Similar Issues:
    • Sprint:
      Declarative backlog

      Description

      I tried the pipeline script below, I get 
           WorkflowScript: 4: "preserveStashes" should have 0 arguments but has 1 arguments instead. @ line 4, column 9.
       

      w/o parameter restart with unstash works (by the way, multiple unstashes in one pipe is working too, as expected!)

       
      http://kie-jenkinslts.ppe.kie.de.heidelberg.com:8080/blue/organizations/jenkins/StashUnstash/detail/StashUnstash/9/pipeline#log-12 preserveStashes(5)
      pipeline

      {     agent \{label 'master'}

          options

      {         preserveStashes(5)     }

          stages{
              stage('create stash'){
                  steps

      {                  //create file                  writeFile file: './myFile.txt', text: 'fun stuff'                  stash includes: '*.txt', name: 'funstufftxt'               }

               }
               stage('unstash first'){
               steps{
                   dir('first') {
                       unstash 'funstufftxt'
                       script

      {                        def funtxt = readFile 'myFile.txt'                        println funtxt                  }

                   }
               }
         }
         stage('unstash second'){

               steps{
                   dir('second') {
                        unstash 'funstufftxt'
                        script

      {                       def funtxt = readFile 'myFile.txt'                       println funtxt                   }

                   }
               }
           }
         }
      }

       

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -

            Interesting and a bit odd - we'll look into it.

            Show
            abayer Andrew Bayer added a comment - Interesting and a bit odd - we'll look into it.
            Hide
            jfravelo JF Ravelo added a comment -

            The problem is that preserveStashes() receives a named parameter, so instead of:

             preserveStashes(5)

            the value has to be passed this way:

             preserveStashes(buildCount: 5)

             

            Show
            jfravelo JF Ravelo added a comment - The problem is that preserveStashes()  receives a named parameter, so instead of: preserveStashes(5) the value has to be passed this way: preserveStashes(buildCount: 5)  
            Hide
            hoppej Jan Hoppe added a comment -

            Yes, that works! The example in https://jenkins.io/doc/book/pipeline/syntax/ should be fixed!

            Show
            hoppej Jan Hoppe added a comment - Yes, that works! The example in https://jenkins.io/doc/book/pipeline/syntax/  should be fixed!
            Hide
            jfravelo JF Ravelo added a comment - - edited

            Btw Andrew Bayer, I think there is a problem of consistency in the docs regarding this point: in Preserving stashes for use with restarted stages it's mentioned as a named parameter, but in Pipeline syntax it's documented as a normal parameter.

            Show
            jfravelo JF Ravelo added a comment - - edited Btw  Andrew Bayer , I think there is a problem of consistency in the docs regarding this point: in Preserving stashes for use with restarted stages  it's mentioned as a named parameter, but in Pipeline syntax  it's documented as a normal parameter.
            Hide
            abayer Andrew Bayer added a comment -

            Yup, that's a doc issue indeed - I'll fix that.

            Show
            abayer Andrew Bayer added a comment - Yup, that's a doc issue indeed - I'll fix that.
            Show
            abayer Andrew Bayer added a comment - Docs PR up at https://github.com/jenkins-infra/jenkins.io/pull/1960
            Hide
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            Show
            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                hoppej Jan Hoppe
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: