Issue
Short explanation:
- There are many repos in our Git
- Each repo has it's own Jenkinsfile who has it's own separate Job at Jenkins
- All Jenkins files are doing 99% the same thing!
What we want to achieve at the moment:
- Build one Jenkinsfile for all repo
- Maintain branches in between repos
- Delete if we can the current Jenkins files of each repo and use the only generic new file.
- Have the versatile to use and manipulate parameters so Jenkins file won't be affected by any other repo config
Solutions for now:
- Remove all Jenkins files in all repos
- Re-configure the Jenkinsfile PATH in Jenkins gui website to direct to our new file
- Put a config .yaml file in each repo who will contains all the relevant information of each repo (like key-value)
- So, when each repo will be triggered, our new Jenkinsfile will load the config file and use the parameters to proceed all the stages related to the config file.
I would be happy to hear ideas / examples / snippets from you guys! It will highly help me!
Regards
Niv
Solution
(Answering due to lack of reputation for comment. Please excuse)
Hi @n1vgabay If you are using Bitbucket for your SCM, then you may try these:
- create a Organization Folder/Bitbucket team Project inside Jenkins (From Jenkins --> New Item--> Organization Folder or Bitbucket team/Project)
- Update the config to filter all the repos (or regex them) under the Project inside your SCM. This will create all the repos as individual MB pipelines with all the branches under them as individual jobs. Also with Bitbucket Server Integration plugin, it automatically creates Webhooks for all the repos to trigger the jobs accordingly upon the events (Push, Commit, PR opened etc)
- Using Remote JenkinsFile provider plugin, you may choose to place your Jenkinsfile elsewhere in another Proj/repo and call them from this config.
- This Jenkinsfile can have all the steps you need and will run the same for all the branches which run as individual MB jobs.
More details on the same can be obtained from here.
Now if you want to use individual jenkinsfiles, then you might have to come up with having Jenkinsfiles specific to each repo which might make it complicated and your Jenkinsfile at the root folder level will have to call the Jenkinsfile present in your repo/branch level across all the repos and branches.
Hopefully this helps! :)
Answered By - Param J