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”
Add a Maven installation and provide a name for it. Click on Save.
Creation of our first build job in Jenkins for a Spring application:
Click on “New Item”
Provide a name for the project and choose “Freestyle Project”
Go to “Source Code Management”, choose “Git”, and provide the Repository URL and the branch.
Developing and viewing of a delivery pipeline of a Spring application with two stages build and test in Jenkins
Transforming your delivery pipeline in the form of scripted/declarative pipeline
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.