Idothisallday
Idothisallday

Reputation: 321

Zip a directory in Jenkins Pipeline

I keep getting this error: "No signature of method: zip.call()"

This is the code i am running in Jenkins pipeline :

pipeline {
   agent any
   stages {
       stage("test..")
       {
            steps
            {
             zip dir: '', glob: '', zipFile: 'testz.zip'
            }
        }
    }
}

I have the zip step appear in sample steps in pipeline syntax, so not sure why this failing. I need to zip my source code folder.

Pipeline Utility Steps plugins is installed : enter image description here

Upvotes: 2

Views: 15343

Answers (2)

Chandara Chea
Chandara Chea

Reputation: 339

Try this:

pipeline {
   agent any
   stages {
       stage("test.."){
          steps{
             script{
                    zip archive: true, dir: '', glob: '', zipFile: 'testz.zip'
             }
          }
       }
    }
}

Reference: https://jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#zip-create-zip-file

Upvotes: 3

Vitalii Vitrenko
Vitalii Vitrenko

Reputation: 10395

Try to wrap zip step with script {}

pipeline {
    agent any
    stages {
        stage("test..") {
            steps {
                script {
                    zip dir: '', glob: '', zipFile: 'testz.zip'
                }
            }
        }
    }
}

Upvotes: 0

Related Questions