AntBuilder:警告:找不到要复制的文件



在这个Jenkinsfile中,我想将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解决了它。我尝试了很多使用groovy复制文件的方法,但都不起作用。

sh """
cp ${sourceDir}${it} ${targetDir}${it}
"""

相关内容

  • 没有找到相关文章

最新更新