在Pipeline脚本语法中,我们使用此语法来声明特定节点的特定步骤:
steps{
node('node1'){
// sh
}
node('node2'){
// sh
}
}
但我想使用Pipeline Declarative Syntax,我可以放多个代理吗?
答案 0 :(得分:4)
当然可以。请看一下示例(来自docs):
pipeline {
agent none
stages {
stage('Build') {
agent any
steps {
checkout scm
sh 'make'
stash includes: '**/target/*.jar', name: 'app'
}
}
stage('Test on Linux') {
agent {
label 'linux'
}
steps {
unstash 'app'
sh 'make check'
}
post {
always {
junit '**/target/*.xml'
}
}
}
stage('Test on Windows') {
agent {
label 'windows'
}
steps {
unstash 'app'
bat 'make check'
}
post {
always {
junit '**/target/*.xml'
}
}
}
}
}