Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manage multiple Jenkins pipelines from a single repository?

At this moment we use JJB to compile Jenkins jobs (mostly pipelines already) in order to configure about 700 jobs but JJB2 seems not to scale well to build pipelines and I am looking for a way to drop it from the equation.

Mainly i would like to be able to have all these pipelines stored in a single centralized repository.

Please note that keeping the CI config (Jenkinsfile) inside each repository and branch is not possible in our use case, we need to keep all pipelines in a single "jenkins-jobs.git" repo.

like image 908
sorin Avatar asked Jul 12 '17 09:07

sorin


People also ask

Can we run multiple pipelines in Jenkins?

Creating Multi-branch Pipelines. The Multibranch Pipeline project type enables you to configure different jobs for different branches of the same project. In a multi-branch pipeline configuration, Jenkins automatically discovers, manages, and executes jobs for multiple source repositories and branches.

How do I create multiple pipelines in Jenkins?

Head over to your Jenkins instance and create a new item. Enter a name for the job, and select the “Multibranch Pipeline” option at the end of the screen. Then, click on the OK button. In the next screen, go to the “Branch sources” tab, click on the “Add source” button, and choose “Git” from the dropdown menu.

What are the 3 types of pipelines in Jenkins?

Different Types of Jenkins CI/CD Pipelines. Scripted Pipeline. Declarative Pipeline.


2 Answers

As far as I know this is not possible yet, but in progress. See: https://issues.jenkins-ci.org/browse/JENKINS-43749

like image 71
Benjamin Avatar answered Nov 16 '22 01:11

Benjamin


I think this is the purpose of jenkins shared libraries

I didn't dev such library my-self but I am using some. Basically:

  • Develop the "shared code" of the jenkins pipeline in a shared library
    • it can contains the whole pipeline (seq of steps)
  • Add this library to the jenkins server
  • In each project, add a jenkinsfile that "import" those using @Library
like image 29
Juh_ Avatar answered Nov 16 '22 02:11

Juh_