PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, September 26, 2022

[FIXED] What is the best way to configure one Jenkinsfile for many repos?

 September 26, 2022     continuous-deployment, continuous-integration, jenkins, jenkins-pipeline, multibranch-pipeline     No comments   

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:

  1. Remove all Jenkins files in all repos
  2. Re-configure the Jenkinsfile PATH in Jenkins gui website to direct to our new file
  3. Put a config .yaml file in each repo who will contains all the relevant information of each repo (like key-value)
  4. 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:

  1. create a Organization Folder/Bitbucket team Project inside Jenkins (From Jenkins --> New Item--> Organization Folder or Bitbucket team/Project)
  2. 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)
  3. Using Remote JenkinsFile provider plugin, you may choose to place your Jenkinsfile elsewhere in another Proj/repo and call them from this config.
  4. 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
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing