How to automate Jenkins build with Github

Automate Build Process

Using Jenkins and Git






These days automating the builds is a commonly observed practice, not only  it saves efforts  and time of a developer, but takes care of updating your server with the latest available code .

Let’s hit our innovation engine this time to make Jenkins team up with Git repo.



Plan of Action -


1. Developer check-ins the code, in Git Repo.
2. Jenkins listens to the event occurred.
3. Jenkins initiates the build and creates a war (in this example).
4. The war is later deployed onto the Apache Tomcat server running.



Requirements -


1. Project on Github. Here for example -




A simple project with a jsp - helloWorld.jsp.


<body>
<h3 style="color: blue"> Message from the project</h3>
</body>
...


2. Tomcat installed. Here I have installed it at this location - /home/jenkins/apache-tomcat-7.0.77, on my Fedora OS.


Start the tomcat server, for this example we have selected port 8081.

3. Download jenkins  and make it up and running.


For Fedora, I used the following commands -
sudo dnf install jenkins // installs
sudo service jenkins start / stop // kicks on/off
sudo chkconfig jenkins on // to monitor



Time to execute -


Once you successfully install Jenkins locally, please refer to the config changes required on the Jenkins dashboard @ localhost:8080. In case you are stuck anywhere take help of the below screenshot. It has the config I have used for this example.





Outcome -

Now whenever any commit is made in the git repo, the build will be triggered, and latest war will be deployed on the Tomcat server.







**
Please note - In case tomcat requires a user to be created, as the below line in - apache-tomcat-7.0.77/conf/tomcat-users.xml


<user username="admin" password="admin" roles="manager-script"/>
**


So here you go, tell at your workplace that you will take care of automating the builds, and enjoy :)


Happy coding !!

No comments:

Post a Comment

Featured post

Oracle SQL Scheduled Jobs - An Interesting Approach

  Oracle SQL Scheduled Jobs A DB Scheduler is the best way to automate any backend database job. For instance, if you want to process the p...