Multiple pipelines in one branch with Jenkinsfile

13,508

You can use declarative pipeline to do this. Create two files in your repo say firstPipeline.groovy and secondPipeline.groovy as follows and configure your jenkins job with the one which you want to build:

enter image description here

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
                }
            }
        }
    }
}
Share:
13,508

Related videos on Youtube

Radoslav Hubenov
Author by

Radoslav Hubenov

Updated on September 16, 2022

Comments

  • Radoslav Hubenov
    Radoslav Hubenov over 1 year

    Is there a way to create two different pipelines for one branch repository? Currently I have one Jenkinsfile and it is manually built using the Jenkins GUI. I want to create a second Jenkinsfile that will also be built trough the Jenkins GUI but I do not know how to have both of these pipelines in the same branch and build whichever I want.