我正在将Jenkins与Pipeline脚本一起使用。在脚本末尾,我想删除/移动某些内容Jenkins\jobs\MyMultiBranch\branches\master\builds(即一些日志和build.xml)。
Jenkins\jobs\MyMultiBranch\branches\master\builds
如何使用管道来完成?我试过了
bat "del /F \"C:\\Program Files (x86)\\Jenkins\\jobs\\MyMultiBranch\\branches\\master\\builds\\%BUILD_NUMBER%\\build.xml\""
但它不起作用,文件仍然存在。有人可以帮忙吗?
Jenkins将无法删除其自己的工作目录确实很有意义。我猜您可以做的就是首先保存要保存的工件(如Daniel所述),然后触发第二项工作(例如delete- job),该job A工作负责清理工作区。它看起来像这样:
delete- job
job A
// First save out anything you want archiveArtifacts artifacts: '**/saveme.log' // At the very end of your pipeline, call delete-job with the path you want to delete as a build parameter build job: 'delete-job', quietPeriod: 5, wait: false, parameters: [[$class: 'StringParameterValue', name: 'folderToDelete', value: "${pathToFolderToDelete}"]]
静默期应足以使delete-job删除job A文件夹。
delete-job 看起来就像这样:
delete-job
node() { bat "del /F '${pathToFolderToDelete}'" }
哪里pathToFolderToDelete是基于作业参数詹金斯自动infered的变量。
pathToFolderToDelete