Continuous Integration is a DevOps practice which will to add new features in production very often. Using this practice, the developers can get their code feedback consistently. So that, developers can fix the project issues and make that module available in production soon.
Jenkins is a CI automation server written in Java. It will automate the end-to-end process of the software project after source code development. Compared with other CI tools, it supports a greater number of plugins to add more functionalities. Plugins play a major role in Jenkins to support all the project features in a single platform.
Basic CI Flow
- Developers develop the source code for the project requirement in their local machine and push the code to the central cloud repository (SCM).
- Continuous Integration tool will poll the source code from SCM and create the build in the configured environment.
- Unit testing, running test cases and building artifacts are some examples for CI build.
- After the successful completion of the CI build, post build activities will start.
- Deploying to server, storing build artifacts, displaying the test results and sending the feedback to developers are some examples for post build activities.
Jenkins in Continuous Integration Process
The main purpose of CI is to test the new features frequently and get the feedback in an automated way. For that, project builds should start periodically or automatically to test the module against the set of functionalities in different environments. In Jenkins, each project is represented as a job. Each Jenkins job contains some set of configurations to do a process.
Created jobs will be displayed in the Jenkins Dashboard. To start the process, Jenkins job should be triggered. It may be manual or automatic based on the project. We can trigger a Jenkins job in multiple ways as follows.
Jenkins Job Trigger Methods
- Enabling this option in the job configuration will automate the job trigger for a specific time regularly.
- By using the cron words, we can set the build interval to Jenkins.
- This will ensure the job to check for SCM changes at a specified time regularly.
- Job will trigger automatically, only if changes happened in the source repository.
- By using the cron words, we can ensure the polling interval to Jenkins.
Trigger after other projects
- Select Build other projects in the post build section of the job configuration to trigger other specified job after completion of current job automatically.
- We can set the status of the current job as a check point to trigger the next one.
Build Now/Build with Parameters
- No need to automate the job trigger for all the projects. Some projects need some manual builds also.
- To trigger the manual build, click on the Build Now/Build with Parameters option in the specific job.
- Build with parameter option is used to provide dynamic values at the time of the build.
- This will trigger the build automatically whenever changes happened in SCM.
- SCM will send a hook to Jenkins for every commit in the repository.
- Jenkins will trigger the build for every notification hook from SCM.
Trigger builds remotely
- Enable this option to build the job remotely without Jenkins login.
- Specific URL of a job with user authorization token will trigger the build.
- This action comes under manual build trigger externally.
Jenkins Job Configuration
- Other than the job trigger options, project functionality related configurations will be there in the job configuration.
- Project functionality configurations are related to
- SCM (e.g. Git, CVS, Subversion, Mercurial)
- Build tool (e.g. Maven, Ant, Gradle)
- Testing framework (e.g. Junit, Selenium, TestNG)
- Build artifact repository (e.g. Nexus, Archiva, Artifactory)
- Configuration Management (e.g. Ansible, Puppet, Chef)
- All configurations together will execute a specific process of the project.
- Developers will get the build feedback immediately.
- No need for separate integration phase in development lifecycle.
- Enabling automated testing in CI server will provide rapid notification on any failure in the source code.
- We can split the total tests as multiple builds to reduce the overall testing time.
- Transparency of developed code among others will increase the code quality.
- Production-ready application available at any point.
- In CI, all code is tested without fail so project outcome will be best in standards.
Jenkins is an open source CI automation server which supports more number of plugins to integrate with many platforms. Plugins provide more flexibility than other CI tools. It is a highly configurable tool. The features are limitless when combing Jenkins with build tools like Maven and Ant. Jenkins has a large support community and more documentation in Internet. All these key functionalities make Jenkins as an unavoidable tool in Continuous Integration phase.
TeamCity, Bamboo, Travis CI, Circle CI and GitLab CI are some other Continuous Integration tools available in the software market.