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

"zip" step is not working according to the documentation

      When using "zip" as per the documentation:

      zip zipFile: '.tmp/management-console.zip', dir: 'dist', archive: true
      

      I receive the following error message:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      WorkflowScript: 30: Invalid parameter "zipFile", did you mean "label"? @ line 30, column 21.
                         zip zipFile: '.tmp/app.zip', dir: 'dist', archive: true
                             ^
      
      WorkflowScript: 30: Invalid parameter "dir", did you mean "url"? @ line 30, column 61.
         .tmp/app.zip', dir: 'dist
                                       ^
      
      WorkflowScript: 30: Invalid parameter "archive", did you mean "url"? @ line 30, column 74.
         app.zip', dir: 'dist', archive: t
                                       ^
      
      3 errors
      
      	at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
      	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1073)
      	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591)
      	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569)
      	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546)
      	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
      	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
      	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
      	at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
      	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:116)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:430)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:393)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:238)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:405)
      
      

      Were the parameters changed? This is the reference I followed: https://jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#code-zip-code-create-zip-file

          [JENKINS-44078] "zip" step is not working according to the documentation

          I'm facing the same issue. Any workaround?

          Mandeep Gulati added a comment - I'm facing the same issue. Any workaround?

          I'm having problems with zip as well on a windows slave. I'm not seeing an error message; the pipeline finishes as if nothing bad happened, but there's no zip file.

          Pipeline code:

          zip dir: "${BuildFolder}", zipFile: "${WORKSPACE}\\${ArtifactName}"
          

          Daniel Dickerson added a comment - I'm having problems with zip as well on a windows slave. I'm not seeing an error message; the pipeline finishes as if nothing bad happened, but there's no zip file. Pipeline code: zip dir: "${BuildFolder}" , zipFile: "${WORKSPACE}\\${ArtifactName}"

          I had the same issue, fixed it by installing pipeline-utility-steps-plugin. I have chosen manual plugins selection on initial Jenkins setup, guess I missed this one or it wasn't installed as dependency.

          Taras Bondarchuk added a comment - I had the same issue, fixed it by installing  pipeline-utility-steps-plugin . I have chosen manual plugins selection on initial Jenkins setup, guess I missed this one or it wasn't installed as dependency.

          Adam Engel added a comment -

          I followed the same advice as aliusmiles and this completely resolved my issue. 

          Adam Engel added a comment - I followed the same advice as  aliusmiles and this completely resolved my issue. 

          Same here, you must install the `Pipeline Utility Steps` plugin, which isn't installed by default with the other pipeline plugins!

          Chris Stylianou added a comment - Same here, you must install the `Pipeline Utility Steps` plugin, which isn't installed by default with the other pipeline plugins!

          I revisited this issue, but didn't manage to reproduce the error from above.

          (I don't think I forgot to install pipeline utility steps though, whatever.)

           

          Paul Garstenauer added a comment - I revisited this issue, but didn't manage to reproduce the error from above. (I don't think I forgot to install pipeline utility steps though, whatever.)  

          Adam Bialas added a comment -

          I do not get any error message but I also do not see any zip created. Is it an expected behaviour when there is no plugin installed?

          Adam Bialas added a comment - I do not get any error message but I also do not see any zip created. Is it an expected behaviour when there is no plugin installed?

          Ivan Fernandez Calvo added a comment - - edited

          I have found the same error, after some time trying to understand why on a simple pipeline works and on a declarative does not, I found that on a script blocks works

          Tested on Jenkins core 2.141, Pipeline Utility Steps 2.1, Pipeline: API 2.9, Pipeline: Step API 2.16, Pipeline: Groovy 2.55, Pipeline: Declarative 1.32

           

          This works

           node(){
               deleteDir()
               sh 'mkdir -p archive'
               sh 'echo test > archive/test.txt'
               zip archive: true, dir: 'archive', glob: '', zipFile: 'coverage-files.zip'
          }
          
          pipeline {
              agent any 
              stages{
                  stage('test'){
                      agent { label 'linux' }
                      steps{
                          deleteDir()
                          sh 'mkdir -p archive'
                          sh 'echo test > archive/test.txt'
                          script{
                              zip archive: true, dir: 'archive', glob: '', zipFile: 'coverage-files.zip'
                          } 
                      }
                  }
              }
          }
          

          This does not work

          pipeline {
              agent any 
              stages{
                  stage('test'){
                      agent { label 'linux' }
                      steps{
                          deleteDir()
                          sh 'mkdir -p archive'
                          sh 'echo test > archive/test.txt'
                          //script{ remove the script block
                              zip archive: true, dir: 'archive', glob: '', zipFile: 'coverage-files.zip'
                          //} 
                      }
                  }
              }
          }
          

          Ivan Fernandez Calvo added a comment - - edited I have found the same error, after some time trying to understand why on a simple pipeline works and on a declarative does not, I found that on a script blocks works Tested on Jenkins core 2.141,  Pipeline Utility Steps  2.1,  Pipeline: API  2.9,  Pipeline: Step API  2.16,  Pipeline: Groovy  2.55,  Pipeline: Declarative  1.32   This works node(){ deleteDir() sh 'mkdir -p archive' sh 'echo test > archive/test.txt' zip archive: true , dir: 'archive' , glob: '', zipFile: ' coverage-files.zip' } pipeline { agent any stages{ stage( 'test' ){ agent { label 'linux' } steps{ deleteDir() sh 'mkdir -p archive' sh 'echo test > archive/test.txt' script{ zip archive: true , dir: 'archive' , glob: '', zipFile: ' coverage-files.zip' } } } } } This does not work pipeline { agent any stages{ stage( 'test' ){ agent { label 'linux' } steps{ deleteDir() sh 'mkdir -p archive' sh 'echo test > archive/test.txt' //script{ remove the script block zip archive: true , dir: 'archive' , glob: '', zipFile: ' coverage-files.zip' //} } } } }

          Using script block help us solve the issue as shown in the example in previous comment by ifernandezcalvo.

          Dragan Marjanovic added a comment - Using script block help us solve the issue as shown in the example in previous comment by ifernandezcalvo .

          Andreas Hetz added a comment -

          i am having the same using already on BlueOcean UI level.

          Andreas Hetz added a comment - i am having the same using already on BlueOcean UI level.

            rsandell rsandell
            rochdev Roch Devost
            Votes:
            11 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated: