如何解决AntBuilder:警告:找不到要复制的文件
在此Jenkins文件中,我想将GitHub中已更改文件的列表复制到新目录/ toucd,然后将其上传到UCD。
我不知道为什么AntBuilder会给我上述错误“找不到要复制的文件”。请帮忙。
stage("list-workspace") {
steps {
sh """
tree ${env.WORKSPACE}
"""
}
}
stage("search-changes") {
steps {
script {
def allChangeFiles = getAllChangeFiles()
if (allChangeFiles.isEmpty()) {
echo "No changed file"
exit 1
}
echo "Consolidated all changed files:"
allChangeFiles.each {
println "# ${it}"
}
String sourceDir = "${env.WORKSPACE}//"
String targetDir = "${env.WORKSPACE}//toucd//"
def ant = new AntBuilder()
allChangeFiles.each {
if (it.endsWith(".xml") || it.endsWith(".bprelease")) {
ant.copy( file:"${sourceDir}${it}",tofile:"${targetDir}${it}")
println "${it} copied"
}
}
} // script
} // steps
} //stage("search-changes")
输出:
> git rev-list --no-walk a836e45cff6d96d294c89e05d5d3aa6719227b70 # timeout=10
14:17:25 + tree /home/jenkins/workspace/BluePrism/Get-Change-List
14:17:25 /home/jenkins/workspace/BluePrism/Get-Change-List
14:17:25 |-- EventAuditPush.sh
14:17:25 |-- GetChangeList_Jenkinsfile
14:17:25 |-- Object
14:17:25 | `-- BPA\ Object\ -\ DevOpsSampleObject1.xml
14:17:25 |-- Process
14:17:25 | `-- BPA\ Process\ -\ DevOpsSampleProcess1.xml
14:17:25 |-- README.md
14:17:25 `-- Release
14:17:25 |-- Release1.1.bprelease
14:17:25 `-- Release1.2.bprelease
14:17:25
14:17:25 3 directories,7 files
14:17:26 [Pipeline] }
14:17:26 [Pipeline] // stage
14:17:28 : Warning: Could not find file /home/jenkins/workspace/BluePrism/Get-Change-List/Release/Release1.2.bprelease to copy.
14:17:28 at org.apache.tools.ant.taskdefs.Copy.copySingleFile(Copy.java:639)
解决方法
我遇到了同样的问题,但是使用shell命令而不是常规的方法解决了它。我尝试了多种使用groovy复制文件的方法,但没有一个起作用。
sh """
cp ${sourceDir}${it} ${targetDir}${it}
"""
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。