Index of / GeniusBrain.IO

Science & Art & Philosophy

Name Date
How To Use Jenkins With Maven – Continuous Integrations

How To Use Jenkins With Maven – Continuous Integrations

Hi everyone, Welcome to Jenkins, I try to explain briefly “How to use Jenkins With Maven” . It is the important tool for Continuous Integrations.

What is Continuous Integrations?
In software engineering, continuous integration is the practice of merging all developers’ working copies to a shared mainline several times a day. Grady Booch first proposed the term CI in his 1991 method, although he did not advocate integrating several times a day.

This is wikipedia answer.

Why We Need?

Why developers need CI? Actually we should say DevOps instead of developer. After the development process, deployment cycle will be started. If your project is running only single machine usually deplotment is doing manually. So this means after the all svn/git merging process developer or DevOps create a builded project. Further DevOps connects to server with ssh and upload the jar file, war file etc… Otherwise open the tomcat, weblogic, jboss glashfish or whatever you use as an application server and upload the builded project. This lifecycle can be useful if you have one or two nodes. On the other hand, if you have more than one node this is really horror story. If an example should be given, the company I work some projects will running on more than 20 nodes. So connecting to all servers and upload files is take a long time.

Of course there are solutions for the problem explained above. Maybe you can write bash script or something like this. However there are also tools for this problem. They can do instead of you. I writed example tools for Continuous Integrations.

Continuous Integrations Tools

I skipped the jenkins installations and you can install on Dockers or directly your machine.

Configure Settings

When you reach the jenkins panel.
Manage Jenkins -> Manage Plugins -> Available
After the this panel you can search “Maven Integration plugin” and “Publish Over SSH Plugin” Install them and you should restart the jenkins.

Manage Jenkins -> Global Tool Configuration -> Maven
You should define maven version. You can show your customized path or you can check “Install Automacitaclly”

If you check “Install Automatically” Maven Path is

Manage Jenkins -> Configure System -> SSH Servers
You have to set your hostname properties.

Congratulations! Now you can create Maven Project as a Jenkins Item. and Your SSH Server Configuration is done!

*Discard old builds
Days to keep builds : 1
Max # of builds to keep : 5

*This project is parameterized
You can give parameter to use branch name or application revision. For example if you use Maven Flatten you should give “-Drevision=”.

Build Environment
You should check “Send files or execute commands over SSH after the build runs”

Build Configuration
If you have multi modular project “pom.xml” is your root file. Moreover you can buid just your sub modules with input the “childprojectname/pom.xml”. Also as you see, I can use my parameter as a flattenRevision

Your configuration is done! Now you can build.

Yes, here is end of article and I hope you see this output.

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.862 s
[INFO] Finished at: 2019-08-16T15:47:40Z
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /var/jenkins_home/workspace/test-project/great/pom.xml to io.geniusbragin/great/4.2.4/great.pom
[JENKINS] Archiving /var/jenkins_home/workspace/test-project/great/target/great.jar to io.geniusbragin/great/great.jar
[JENKINS] Archiving /var/jenkins_home/workspace/test-project/great/target/great.jar to io.geniusbragin/great/great.jar
channel stopped
SSH: Connecting from host [3d570c526982]
SSH: Connecting with configuration [hostName] ...
SSH: Disconnecting configuration [hostnAME] ...
SSH: Transferred 1 file(s)
Finished: SUCCESS

About Post Author

Tags: , , , , ,

Leave a Reply