Blog Continuous Integration

Continuous Integration with Jenkins And GitHub

December 19, 2018
Continuous Integration with Jenkins And GitHub

Jenkins is an open source Continuous Integration tool written in Java with plugins built to fasten deployment cycle by continuous testing.

Workflow of Continuous Integration with Jenkins

The below snapshot shows the workflow of continuous integration with Jenkins.

CI with Jenkins GitHub

Creating Simple Jenkins job with Github

For Jenkins Installation and Setup refer Jenkins documentation.

Before creating a Jenkins job I have created a Git repository and added a sample file to it. Here is my sample file (example.java).

sample code

The snapshot shows the sample repository.

Git repository

Step 1: Click on ‘New Item’ to create a new Jenkins job.

Jenkins - new job

Step 2: Enter the name of Jenkins job, Choose ‘Freestyle Project’  and Click ‘OK’.

Jenkins -job name and style

Step 3: Enter Job Description if necessary(Optional).

Step 4: Select Source Code Management as ‘Git’ and paste the Repository URL of your Git repository.

Jenkins - Git configuration

Step 5: Under Build Triggers select ‘Poll SCM’ and define the schedule for the trigger.

Note: Here schedule is given as ‘* * * * *’ which means to schedule trigger for every minute. To know more about the schedule description click help.

Jenkins - scheduling build trigger

Now the Job checks Git repository once every minute for changes and triggers Build if any changes made in the Git repository.

Step 6: Under Build, Choose ‘Execute Windows batch command’ if you were running Jenkins in windows environment (or) Choose ‘Execute shell’ if you were running Jenkins in Linux environment.

Jenkins - Adding Build steps

Step 7: Enter the commands for the build and click save.

Jenkins - Build commands

The Jenkins project is created now.

Jenkins - Job created

Continuous Testing Using Jenkins

When code committed into the repository. Here ‘example.java’ file is changed and committed.

sample code 2

Jenkins Build automatically triggered on code commit.

Jenkins - Build running

 

The output is displayed on the console output like below.

Jenkins - Build output

Hope this blog serves as a good feed for your technology cravings. Bags of interesting stuff are down the pipeline and do stay subscribed to get notified about those.

References

https://jenkins.io/doc/

https://www.edureka.co/blog/jenkins-tutorial/

https://www.tutorialspoint.com/jenkins/

Leave a Reply