VOOZH about

URL: https://www.javacodegeeks.com/2021/01/jenkins-automating-your-delivery-pipeline.html

⇱ Jenkins: Automating your delivery pipeline - Java Code Geeks


In this post, we are going to create a Jenkins pipeline for a Java Spring project using Maven and Git:

Accessing Jenkins dashboard and configuring Maven in Jenkins:

Click on “Manage Jenkins” and then in “Global Tool Configuration”

👁 Image

Add a Maven installation and provide a name for it. Click on Save.

👁 Image

Creation of our first build job in Jenkins for a Spring application:

Click on “New Item”

👁 Image

Provide a name for the project and choose “Freestyle Project”

👁 Image

Go to “Source Code Management”, choose “Git”, and provide the Repository URL and the branch.

👁 Image

Go to the “Build” tab and choose “Invoke top-level Maven targets”
👁 Image

Choose the Maven Version, write compile in the goals and click on “Save”
👁 Image

Click on “Build Now”
👁 Image

Click on “Console Output” in the first build of the Build History section
👁 Image

Confirm the “SUCCESS” message is displayed when finished
👁 Image

Developing and viewing of a delivery pipeline of a Spring application with two stages build and test in Jenkins

Let’s create a New Item
👁 Image

Enter an item name, choose the “Freestyle project” and click OK
👁 Image

Go to the “Source Code Management” tab, select “Git”, provide the URL of the Repository, and the branch
👁 Image

Go to the “Build” tab and choose “Invoke top-level Maven targets”
👁 Image

Choose the Maven Version, write test in the goals and click on “Save”
👁 Image

Click on “Build Now”
👁 Image

Click on “Console Output” in the first build of the Build History section
👁 Image

Confirm the “SUCCESS” message is displayed when finished
👁 Image

To do it automatically after the compile job, let’s go to the “Configure” option of the item
👁 Image

Go to the “Build Triggers” section and select the “Build after other projects are built” option. Then, enter the other project name, and click “Save”
👁 Image

Go to the “Manage Jenkins” option in the main menu and choose “Manage Plugins”
👁 Image

Go to the “Available” tab and look for “Build pipeline”. Choose it and click on “Install without Restart”
👁 Image

Choose the plus symbol in the main dashboard
👁 Image

Choose the “Build Pipeline View” option, provide a view name, and click on “OK”
👁 Image

Select the initial job and click ok
👁 Image

Click “Run”
👁 Image

Transforming your delivery pipeline in the form of scripted/declarative pipeline

First, install the “Pipeline Maven Integration Plugin”
👁 Image

Now, let’s create a new item (Pipeline)
👁 Image

Then, go to the “Pipeline” tab and choose “Scripted Pipeline” or “GitHub + Maven” for a declarative pipeline
👁 Image

Finally, adapt the code according to your needs, and click on “Save”
👁 Image

If you click on “Build Now” you can see the result
👁 Image

Developing a Jenkinsfile for our application

If you chose “GitHub + Maven” for a declarative pipeline you can copy that code into a Jenkinsfile in the root of your project. Now, edit the Pipeline and select “Pipeline script from SCM”. Then, choose Git as your SCM and provide the Repository URL and branch. Finally, click “Save” and “Build now” to test your pipeline.
👁 Image

Published on Java Code Geeks with permission by Eidher Julian, partner at our JCG program. See the original article here: Jenkins: Automating your delivery pipeline

Opinions expressed by Java Code Geeks contributors are their own.

Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy

Thank you!

We will contact you soon.

👁 Photo of Eidher Julian
Eidher Julian
January 9th, 2021Last Updated: January 7th, 2021
0 282 2 minutes read

Eidher Julian

Eidher Julian is a Systems Engineer and Software Engineering Specialist with 13+ years of experience as a Java developer. He is an Oracle Certified Associate and SOA Certified Architect.
Subscribe

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Back to top button
Close
wpDiscuz