在特定的jenkins节点上为每个测试运行postbuild操作

时间:2020-04-16 10:23:33

标签: jenkins

我的jenkins服务器上有一个远程代理和多个本地代理。我有一个脚本,仅在那些基于远程代理构建的测试之后才想运行。有可能吗? 谢谢

1 个答案:

答案 0 :(得分:-1)

使用jenkins管道,您可以根据构建结果来执行操作。在这里看看:

https://jenkins.io/doc/book/pipeline/syntax/#post

您甚至可以将构建分为多个“阶段”,并使用相同的方法根据阶段的结果运行操作。

在整个管道上,或在特定阶段,甚至在您的后期操作上,您都可以选择执行该操作的节点。

考虑到您可以在特定节点上运行舞台,

pipeline {
    stages {
        stage ('Build') {
            agent { label "SLAVE1" }
            steps {
                // Stuff to do
            }
            post {
                 always {
                     // stuff
                 }
            }
        }
    }
}

或者在发布区的管道末端:

pipeline {
    stages {
        stage ("Build") {
            agent { label "SLAVE" }
            steps {
                // stuff
            }
        }
    }
    post {
        // Or failure, unstable, success...
        always {
            node('SLAVE1'){
                // stuff
            }
        }
    }
}