提问人:DeadlyHigh 提问时间:11/15/2023 更新时间:11/15/2023 访问量:24
如何防止 Jenkins Pipeline 代理从主机的插槽中占用一个插槽
How to prevent Jenkins Pipeline agent from taking one slot from the main machine's slots
问:
我有以下Jenkins Pipelines脚本:
pipeline{
agent any
stages {
stage('First Step'){
agent { label 'TheSecondAgent'}
steps {
... Do stuff
}
}
}
stage('Second Step'){
agent { label 'TheSecondAgent'}
steps {
... Do even more stuff
}
}
}
... Bunch more steps here
stage('Archive Artifacts'){
agent {
node { label 'TheSecondAgent'
customWorkspace 'another/path/where/artifacts/are'
}
}
steps {
archiveArtifacts artifacts: '**/logs/*.xml, **/logs/*.json, **/logs/*.log', followSymlinks: false
}
}
}
post {
always{
node('TheSecondAgent'){
dir('path/to/logs'){
xunit(tools: [ xUnitDotNet(pattern: '**/logs/*-jenkinsLogs.xml') ])
}
}
}
}
}
正如我们所看到的,此管道中的每个步骤都设置了另一个代理。但是,当我运行此作业时,我仍然可以看到,这从主 Jenkin 的插槽以及代理的插槽中占用了一个插槽。
以前,通过将此管道顶部的代理设置为 none 来修复此问题,但这会阻止我使用 Artifacts 和 post builds,因此它必须为“任何”......我认为。
有没有办法“阻止”或以某种方式“强制”此脚本仅在代理计算机中运行,在本例中为名为:TheSecondAgent的代理?
答: 暂无答案
评论
any
{ label 'TheSecondAgent' }
post
mv
rsync