有没有办法为一个分支存储库创建两个不同的管道? 目前我有一个 Jenkinsfile,它是使用 Jenkins GUI 手动构建的。我想创建第二个 Jenkinsfile,它也将通过 Jenkins GUI 构建,但我不知道如何将这两个管道放在同一个分支中并构建我想要的任何一个。
最佳答案
您可以使用声明式管道来执行此操作。在你的 repo 中创建两个文件,比如 firstPipeline.groovy 和 secondPipeline.groovy,如下所示,并使用你想要构建的那个配置你的 jenkins 作业:
firstPipeline.groovy:
pipeline {
stages {
stage('stage 1') {
steps {
script{
//do your things of first pipeline stage
}
}
}
stage('stage 2') {
steps {
script{
//do your things of first pipeline stage
}
}
}
}
}
secondPipeline.groovy:
pipeline {
stages {
stage('stage 1') {
steps {
script{
//do your things of second pipeline stage
}
}
}
stage('stage 2') {
steps {
script{
//do your things of second pipeline stage
}
}
}
}
}
关于git - 使用 Jenkinsfile 一个分支中的多个管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51932696/