无法在jenkins管道脚本中运行ant.zip/ ant.tar任务

时间:2016-04-22 05:40:21

标签: jenkins groovy ant jenkins-workflow

我正在尝试在管道脚本中运行ant zip任务。但这是一个错误:

Problem creating zip: /abc.zip (Permission denied) (and the archive is probably corrupt but I could not delete it)
    at org.apache.tools.ant.taskdefs.Zip.executeMain(Zip.java:741)
    at org.apache.tools.ant.taskdefs.Zip.execute(Zip.java:568)

Caused by: java.io.FileNotFoundException: /abc.zip (Permission denied)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)

然而,我尝试使用安装了groovy的Windows机器上的命令行来做同样的事情。当我能够运行蚂蚁任务时......

我的管道脚本是这样的:

    def createArtifacts() {
        def root = pwd()
        def services = ["abc", "def"].toArray()

        for (int i = 0; i < services.size(); i++) {
            dir(root + "\\src\\" + services[i]) {
                echo("Trying to create zip package")

                def ant = new AntBuilder()
                ant.zip(destfile: "${services[i]}.zip", basedir: 'bin')
            }
        }
    }

    node('windows') {
        stage 'Archive artifacts'
        createArtifacts()
    }

0 个答案:

没有答案