Reputation: 305
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.
Upvotes: 13
Views: 22122
Reputation: 1561
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:
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
}
}
}
}
}
Upvotes: 15