我正在尝试创建一个连续的部署管道,其中测试将在任何节点上运行,但是条件部署需要在特定节点上运行。
仅当活动分支为master时,部署才需要运行。
示例代码:
pipeline {
agent any
stages {
stage('Test') {
agent { label 'nodes' }
steps {
sh ''' # code to run tests '''
}
}
stage('Deploy') {
when {
branch 'master'
}
agent { label 'specific-node' }
steps {
sh ''' # code to deploy '''
}
}
}
问题在于Deploy阶段不需要在90%的运行(拉取请求)上运行,但是条件是在specific-node
上评估的,因此它成为瓶颈资源。 / p>
有没有办法评估主节点或上一个节点上的条件,并仅在实际需要时才在specific-node
上运行下一个阶段?