Friday, September 20, 2019

Post#102.Setup Pipeline in Jenkins



Install Build Pipeline Plugin in Jenkins

Step#1. The settings for the plugin can be found under Manage Jenkins > Manage Plugins.


If you have already installed the plugin, it is shown under the installed tab. If you do not have the plugin previously installed, it shows up under the Available tab.




Create Jenkins Pipeline

Before creating Jenkins Pipeline create Jenkins Jobs first. (Discussed the steps to create Jobs)
Here I am creating 3 Jenkins Jobs for demo purpose.
Let's name as Job1, Job2 and Job3.
Job3 is depends on Job2 and Job2 is depends on Job1.

So the Pipeline sequence will be like below
So in order to make the above dependencies refer the below settings.

Navigate-Job2->Configure-> Build Triggers.


Select Build after other projects are built checkbox. Then enter the Project name (Job name) in Project to watch textbox and select Trigger only if build is stable option. I have entered Job1. This means Job2 build will be triggered   once the Job1 build is stable (Build Success).


Similarly you do the settings for Job3 as below.


Now let's create Jenkins pipeline for the above Jobs.
Once you are logged in to your Jenkins dashboard:
Step #1. Click on the "+" button on the left-hand side of your Jenkins dashboard to create a pipeline.


Step#2. Enter View Name 'Build Pipe Line' and select Build Pipeline View then click on OK button.



Step#3. Select Job1 under Select Initial Job then click on Apply and OK.

*The initial Job (Job1) is nothing but your Parent Job.
Step#4. Select No Of Displayed Builds. Click on Apply->OK.



Step#5. Once Pipeline setup is done you will be navigate to below page. 



Step#6. Now click on Run button to execute Pipeline.

The Jobs will start executing in sequence. i.e. Job1->Job2->Job3. Refer the below images for better understanding.


Image-1 Job1 is Running.


Image-2  Job2 is Running after succesful execution of Job1


Job3 will also execute after successful execution of Job2.


Note: If you want to trigger the pipeline in a particular time, schedule the parent job (Job1 in this case) in a specific time. So that rest dependent jobs will be triggered automatically.



No comments:

Post a Comment