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

"zip" step is not working according to the documentation

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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

        Attachments

          Issue Links

            Activity

            Hide
            chris5287 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!

            Show
            chris5287 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!
            Hide
            p_garstenauer 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.)

             

            Show
            p_garstenauer 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.)  
            Hide
            adambialas 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?

            Show
            adambialas 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?
            Hide
            ifernandezcalvo 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'
                            //} 
                        }
                    }
                }
            }
            
            Show
            ifernandezcalvo 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' //} } } } }
            Hide
            marjanovic Dragan Marjanovic added a comment -

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

            Show
            marjanovic Dragan Marjanovic added a comment - Using script block help us solve the issue as shown in the example in previous comment by Ivan Fernandez Calvo .

              People

              Assignee:
              rsandell rsandell
              Reporter:
              rochdev Roch Devost
              Votes:
              10 Vote for this issue
              Watchers:
              15 Start watching this issue

                Dates

                Created:
                Updated: