Jenkins Pipeline Utility Steps - zip zipFile

前端 未结 4 573
没有蜡笔的小新
没有蜡笔的小新 2021-01-11 15:30

I am trying to zip the folders which are created as output of my jenkins pipeline job using pipeline script. By googling i came to know the Jenkins

P

4条回答
  •  無奈伤痛
    2021-01-11 15:36

    First, try the same operation in stages and step, as in here:

    pipeline {
        agent any
        stages {
            stage ('push artifact') {
                steps {
                    sh 'mkdir archive'
                    sh 'echo test > archive/test.txt'
                    zip zipFile: 'test.zip', archive: false, dir: 'archive'
                    archiveArtifacts artifacts: 'test.zip', fingerprint: true
                }
            }
            ...
        }
    

    It uses archiveArtifacts to record the result.

    If using an absolute path does now work, try a relative one ('..')

    As seen by the OP Sri, zip zipFile is part of, and requires the JENKINS Pipeline Utility Steps Plugin.
    See "Implemented Steps".


    Regarding the syntax to be used for multi-criteria file selection, NicolasW notes in the comments that the documentation is vague: "use glob ant-style syntax"...
    He got it to work though, with a basic coma separated syntax.
    E.g.

    zip zipFile: 'test.zip', archive: false, glob: 'config-/**/,scripts/**/*.*
    

提交回复
热议问题