这是我所拥有的:
#!/usr/bin/env groovy
pipeline {
agent none
stages {
stage('Checkout SCM') {
agent { label 'win' && 'apple' && 'rhel' }
steps {
echo "Cloning Repository"
checkout([$class: 'GitSCM',
branches: [[name: "*/develop"]],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'WipeWorkspace']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'UNAME', url: 'URL']],
browser: [$class: 'BitbucketWeb', repoUrl: 'URL'],
])}}
stage('Building Win64, Linux764, MacOS') {
agent { label 'win&&rhel&&apple' }
steps {
script {
echo '************************'
echo '*****BUILDING JOBS******'
echo '************************'
sh 'python build.py'
sh 'cd ion-js && npm run prepublishOnly'
}}}
}
}
但是我得到了
There are no nodes with the label ‘win && rhel && apple’
错误。有没有人碰巧知道如何运行声明性 jenkins 管道,其中一个阶段在多个代理标签上并行运行?我想同时将同一个 git repo checkout 到 3 个不同的节点。我试过
agent { label 'win' && 'apple' && 'rhel' }
和 agent { label 'win&&apple&&rhel' }
但它只是说它找不到那个标签。Here they say you can use
||
并使用 &&
应该可以,但我不确定我错过了什么。我可以编写 3 个不同的结帐阶段,但我认为有更好的方法
最佳答案
我尝试过同样的事情但没有成功。我知道的唯一解决方案是使用 parallel
为每个代理/节点/标签多次阻止和定义阶段。
stage('Building Win64, Linux764, MacOS') {
parallel {
stage('Win64') {
agent {
label 'win-10-x64'
}
steps {
...
}
}
stage('Linux64') {
agent {
label 'linux-x64'
}
steps {
...
}
}
stage('MacOS') {
agent {
label 'macos'
}
steps {
...
}
}
}
}
关于jenkins - 在声明性管道中并行在多个代理上运行相同的 Jenkins 作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48930433/