Professional Documents
Culture Documents
In this tutorial, we will see how to use Jenkins, Git and maven to set up a CI/CD pipeline. We will use
the spring boot project from this gitlab link. If you wish you can use a maven project of your choice ;)
Prerequisite
JDK 11 or above
Maven
A linux server
After following the jenkins installation procedure, you can check if the service is installed
correctly.
as you see , the service is installed but inactive , so we need to start it with :
now the service is started , now on your browser type http://<your-host>:8080 , the first connection
show you this :
https://www.thetechmonitor.com/post/ci-cd-with-git-jenkins-and-maven 1/13
30/05/2023, 21:59 CI/CD with Git, Jenkins and Maven
in order to have your password open the file /var/lib/jenkins/secrets/initialAdminPassword and get the
password .
you will be asked to install the most used plugins. in our tutorial we put yes.
for the rest we have skipped all the other requests, and we obtain the page below:
https://www.thetechmonitor.com/post/ci-cd-with-git-jenkins-and-maven 2/13
30/05/2023, 21:59 CI/CD with Git, Jenkins and Maven
git version
https://www.thetechmonitor.com/post/ci-cd-with-git-jenkins-and-maven 3/13
30/05/2023, 21:59 CI/CD with Git, Jenkins and Maven
From Jenkins Dashboard Manage Jenkins -> Manage Plugins. On plugin manager page , on
Available option search gitlab , choose it and click on Install without restart
https://www.thetechmonitor.com/post/ci-cd-with-git-jenkins-and-maven 4/13
30/05/2023, 21:59 CI/CD with Git, Jenkins and Maven
Go to maven download page https://maven.apache.org/download.cgi and get one binary link and with
wget tool download the binary on /opt folder of the host :
mv apache-maven-3.8.6 maven
edit the file .bash_profile , in order to declare JAVA_HOME, M2_HOME, M2 and update $PATH as
below:
vi ~/.bash_profile
https://www.thetechmonitor.com/post/ci-cd-with-git-jenkins-and-maven 5/13
30/05/2023, 21:59 CI/CD with Git, Jenkins and Maven
M2_HOME=/opt/maven
M2=/opt/maven/bin
JAVA_HOME=/usr/lib/jvm/<YOUR JAVA>
PATH=$PATH:$HOME/bin:$JAVA_HOME:$M2_HOME:$M2
source ~/.bash_profile
check maven and java version by typing mvn -version and java -version
From Jenkins Dashboard Manage Jenkins -> Manage Plugins. On plugin manager page , on
available option search maven , choose it and click on Install without restart
On global Tool Configuration complete JDK section and maven section as below:
https://www.thetechmonitor.com/post/ci-cd-with-git-jenkins-and-maven 7/13
30/05/2023, 21:59 CI/CD with Git, Jenkins and Maven
https://www.thetechmonitor.com/post/ci-cd-with-git-jenkins-and-maven 8/13
30/05/2023, 21:59 CI/CD with Git, Jenkins and Maven
After save
https://www.thetechmonitor.com/post/ci-cd-with-git-jenkins-and-maven 9/13
30/05/2023, 21:59 CI/CD with Git, Jenkins and Maven
if everything ok we have :
https://www.thetechmonitor.com/post/ci-cd-with-git-jenkins-and-maven 10/13
30/05/2023, 21:59 CI/CD with Git, Jenkins and Maven
https://www.thetechmonitor.com/post/ci-cd-with-git-jenkins-and-maven 11/13
30/05/2023, 21:59 CI/CD with Git, Jenkins and Maven
on console output :
We use port 9999 , because Jenkins use the port 8080 on the . Our application is normaly configured
to use port 8080 , but in this test case we forced the port to 9999.
If your application uses another port other than 8080, you don't need to use the server.port option
when starting.
Step 5 : Conclusion
With this tutorial, we have seen how to easily install Jenkins on Centos and do the necessary to be
able to build a spring boot project in simple CI/CD mode.
https://www.thetechmonitor.com/post/ci-cd-with-git-jenkins-and-maven 13/13