DevOps Series: An Expert Guide On Jenkins

Guide On Jenkins

Previous Blog: DevOps Series

  • What is Jenkins?

    • Jenkins is an open source automation tool written in Java with plugins built for Continuous Integration and continuous delivery application, which increases overall productivity. Jenkins integrates development life-cycle processes of all kinds, including build, stage, test, deploy, package, document, static analysis and much more.


  • Use case of Jenkins:

    • Deploys directly to the development or production environments.

    • Immediate testing of all changes.

    • Perform a software build using a build system like Apache Maven or Gradle.

    • Execute a shell script.

    • Archive a build result.

    • Jenkins monitors the execution of the steps and allows to stop the process if one of the steps fails. Jenkins can also send out the notification in case of a build success or failure.

    • A feature of executing multiple jobs simultaneously saves you the test-execution time.

    • Once the project is configured in Jenkins then all future builds are automated. It has basic reporting features like status and weather reports (job health).

Diagram depicting how Jenkins integrates various DevOps stages:

Jenkins integrates various DevOps stages

Continuous Integration and Development With Jenkins:

Let us imagine a scenario where the complete source code of the application was built and then deployed on a development server or production server. First, a developer commits the code to the source code repository (Github, Gitlab, bitbucket). Meanwhile, the Jenkins server checks the repository at regular intervals for changes or source code trigger build by webhooks. After the developer commits the source code to the repository, the Jenkins server detects the changes occurred in the source code repository and pull those changes and will start preparing the new build job. If Jenkins build job fails then concerned teams will be notified of the failure status. If the build is successful, then Jenkins server deploys the source code on development or production servers. With Jenkins, organizations can accelerate the software development process through automation.

Jenkins Architecture:

Jenkins Architecture
  • Setting up Jenkins build job:

Start by creating a new item. Choose Build Freestyle project as a job type and enter a job name:

Setting up Jenkins build job
GitHub project
  • Source Code Management:
    • In the ‘Source Code Management’ section select the ‘Git’ radio and enter the same GitHub project URL in the ‘Repository URL’ field. Click the ‘Add’ button next to the ‘Credentials’ drop down.

Source Code Management
  • In the form that comes up, select “SSH Username with private key” from the “Type” drop-down. The “Username” should be the username for the GitHub account which hosts the project. Select the “From the Jenkins master ~/.ssh” radio option. Then click “Add”.
Jenkins master
  • Configure pre-build or post-build:
    • Now in the pre-build session, write a shell script or other various tasks to perform when concerned teams commit source code on repository and Jenkins build job triggered. In post build session it will notify the concerned teams with job status.

Configure pre-build or post-build


Now each time the developer will make a commit source code to GitHub repository on ‘dev’ branch. The ‘website’ job will run, building your project from that branch on your Jenkins server, running tests and move the new build to the ‘website’ directory on your deploy server. If the automated tests do not pass, the build will fail without deploying and notify the concerned teams about the same. We can look at the console log for that build to find the reason and re-work on them.

I hope this blog helps you to expand your Jenkins knowledge …Thanks! If you need more assistance regarding DevOps Services, feel free to contact us now.