Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipeline multiple jenkins jobs

I am very new to Jenkins.

There are multiple jobs already configured in Jenkins, As of now we are running all the jobs manually one after the other. I want to make it a single job by pipeline plugin, So that manual effort is reduced.

I had gone through the links, It states we should have JenkinsFile in our repository it basically contains command's to execute the different tasks.

But if i am configuring it in JenkinsFile how can give the existing job names ?

Is it the only way to do a pipeline or is there any other way to achieve this ?

Ex : I have three jobs

  1. build-dev-code
  2. test-dev-code
  3. deploy-stage

I would like to pipeline all the three jobs,

  deploy-stage-ci 

So that it contains all the 3 above mentioned jobs.

like image 357
Jay Avatar asked Dec 26 '16 10:12

Jay


People also ask

Do I need A Jenkins file to use pipeline?

You don't always need a Jenkinsfile to use Pipeline. In your Pipeline job, choose "Pipeline Script" from the dropdown to get a script editor. To build your three jobs sequentially, in a pipeline, use the following script (using names from your example). It simply wraps each job in a stage and builds it.

How do I create a multi branch pipeline in Jenkins?

Create Multibranch Pipeline on Jenkins (Step by Step Guide) Step 1: From the Jenkins home page create a “new item”. Step 2: Select the “Multibranch pipeline” from the option and click ok. Step 3: Click “Add a Source” and select Github.

How do I build multiple jobs sequentially in a pipeline?

In your Pipeline job, choose "Pipeline Script" from the dropdown to get a script editor. To build your three jobs sequentially, in a pipeline, use the following script (using names from your example). It simply wraps each job in a stage and builds it.

How do I run a Jenkins project from GitHub?

Step 1: From the Jenkins home page create a “new item”. Step 2: Select the “Multibranch pipeline” from the option and click ok. Step 3: Click “Add a Source” and select Github. Step 4: Under the credentials field, select Jenkins, and create a credential with your Github username and password.


1 Answers

You don't always need a Jenkinsfile to use Pipeline. In your Pipeline job, choose "Pipeline Script" from the dropdown to get a script editor. Pipeline script editor

To build your three jobs sequentially, in a pipeline, use the following script (using names from your example). It simply wraps each job in a stage and builds it. This will also give you a pretty stage view while it runs your jobs:

stage('Build') {
  build 'build-dev-code'
}
stage('Test') {
  build 'test-dev-code'
}
stage('Deploy') {
  build 'deploy-stage'
}
like image 71
badgerr Avatar answered Nov 08 '22 20:11

badgerr