I have a project in a monorepo with 2 artifacts : a frontend and a backend.
my-project
frontend
Jenkinsfile
backend
Jenkinsfile
I'd like to use Blue Ocean and multibranch pipeline but is there a way to use two Jenkinsfile
and two pipelines ? Afaik, the Jenkinsfile need to be at the root of the repo.
Otherwise, I will use classic pipeline but I will need to create a new pipeline for each new branch, which is painful.
Create two multibranch-pipelines: MyProjectFrontEnd and MyProjectBackEnd.
Then in the Jenkinsfile you have the following
#!/usr/bin/env groovy
// Get MyProjectFrontEnd from MyProjectFrontEnd/master
switch(env.JOB_NAME.split("/")[0])
{
case 'MyProjectFrontEnd':
project = 'front'
break
case 'MyProjectBackEnd':
project = 'back'
break
default
project = ''
break
}
if (project == 'front') {
// Place your build steps here for front
}
if (project == 'back') {
// Place your build steps here for back
}
Now your single Jenkinsfile will determine which pipeline job is building it and then run the correct pipelines.
Alternatively you can make a single pipeline where you just instantiate the correct variables in the switch so you build the correct artifacts.
Having not used Blue Ocean, I'm not sure how well these pipelines visualize.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With