我目前正在尝试触发现有作业并接收生成的作业 当前作业工作区中的工件。
以下工作正常:
pipeline {
agent {
label 'builder-rpm'
}
options {
timestamps()
ansiColor('xterm')
}
stages {
stage('Build Other pipeline') {
steps {
build job: 'Components/components-rpm-build', parameters: [
string(name: 'Component', value: 'foo'),
]
copyArtifacts(
filter: 'results/*.rpm',
fingerprintArtifacts: true,
flatten: true,
projectName: 'Components/components-rpm-build',
selector: lastSuccessful(),
target: "${env.WORKSPACE}/dist"
)
}
}
}
}
问题在于lastSuccessful()
确实会占据最后一个
成功构建,意味着如果其他用户设法运行并行
比我快,我会接受他们的文物而不是我的。
根据this page
应该有一种方法可以使用specific
:
def built = build('downstream');
copyArtifacts(projectName: 'downstream',
selector: specific("${downstream.number}"));
然而,如果在声明中使用它没有解释或示例 管道
任何提示?
提前感谢您的帮助。
答案 0 :(得分:0)
我找到了一些不错的解决方案:切换到script
只是完成了工作。
pipeline {
agent {
label 'builder-rpm'
}
options {
timestamps()
ansiColor('xterm')
}
stages {
stage('Build Other pipeline') {
steps {
script {
def built = build(
job:'Components/components-rpm-build',
parameters:[
string(name:'Component', value:'ew-filesystem'),
string(name:'RepoServer', value:'')
]
)
copyArtifacts(
projectName: 'Components/components-rpm-build',
selector: specific("${built.number}"),
target: "${env.WORKSPACE}/dist",
filter: "results/*"
)
}
}
}
}
}