• Declarative backlog

      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                   }

                   }
               }
           }
         }
      }

       

          [JENKINS-54386] preserveStashes does not work with parameter

          Andrew Bayer added a comment -

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

          Andrew Bayer added a comment - Interesting and a bit odd - we'll look into it.

          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)

           

          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)  

          Jan Hoppe added a comment -

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

          Jan Hoppe added a comment - Yes, that works! The example in https://jenkins.io/doc/book/pipeline/syntax/  should be fixed!

          JF Ravelo added a comment - - edited

          Btw abayer, 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.

          JF Ravelo added a comment - - edited Btw  abayer , 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.

          Andrew Bayer added a comment -

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

          Andrew Bayer added a comment - Yup, that's a doc issue indeed - I'll fix that.

          Andrew Bayer added a comment -

          Andrew Bayer added a comment - Docs PR up at https://github.com/jenkins-infra/jenkins.io/pull/1960

          Liam Newman added a comment -

          Bulk closing resolved issues.

          Liam Newman added a comment - Bulk closing resolved issues.

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

              Created:
              Updated:
              Resolved: