Devops Tutorial 24 - Jenkins Build Pipeline
What you will Learn:
Create and chain jobs
Setup Build pipeline (install ‘Build pipeline’ plugin)
Add ‘Build Pipeline’ view
Run pipeline
Configure pipeline
Open console for a job
Re-run a job in the pipeline
Create and chain jobs
Create 3 simple freestyle jobs
Select ‘Execute shell’ from the ‘Add build step’ dropdown and enter an echo statement, see below
Apply and save
Similarly create ‘DeployJb2’
Similarly create ‘TestJb2’
So we have created 3 jobs
Important note: Make sure that 3 jobs are running fine individually
Chain jobs
We will now chain the 3 jobs. Configure DeployJb2 first
Select ‘Build after other projects are built’ checkbox
Enter ‘BuildJb2’ in the text field
Apply and Save
Similarly configure ‘TestJb2’.
So we have chained the 3 jobs.
To validate the chaining, manually execute ‘BuildJb2’.
Notice below that DeployJb2 gets executed automatically
Similarly TestJb2 gets executed automatically
Install ‘Build pipeline’ plugin
Install ‘Build pipeline’ plugin
Important note: Restart jenkins after installing plugin
Add ‘Build Pipeline’ view
Click + sign
Enter view name and select ‘Build Pipeline view’
Click Ok
Select Initial Job
Apply and Ok
You can see the view of last run (if any)
Run pipeline
Click ‘Run’ button
Refresh the page, you will see the new pipeline gets triggered
Refresh the page, notice that execution is over
Configure pipeline
Click Configure
Select 3 from the dropdown ‘No Of Displayed Builds’
Apply and Ok
You can now see last 3 builds displayed
If needed, you can click the link under a job to see the details
Open console for a job
You can also click the small black square window to open the console for a respective job
If you don’t see the console window, click and select ‘New Window’ from the dropdown ‘Console Output Link Style’, click Apply and Ok
Re-run a job in the pipeline
You can click the yellow coloured forward arrow to re-run the job
When you click the arrow, the job gets triggered on the same pipeline
Once complete, you would see the new build number (#6 as seen below) only on the job that was rerun. Other jobs still have old build number
Refresh the page, you would now see new build number on each job (#6 below)
So this is how we create a ‘Build pipeline’.
Thank you for reading!