David RomeroSoftware EngineerFor several years I have a hard goal. I want to become a great software engineer, so I work hard developing quality software every day. Fan of new technologies. I will not stop until overcome my goals.
Since the beginning of 2017, I have been instilling in my company the importance and necessity of having a strong CI environment. I started installing Jenkins in a small server and right now I’ve got a project to implement continuous integration for all the development teams in the company.
In this post I would like to share many of the acquired knowledge.
Workflow definition
First of all, we have designed a workflow for all projects. If each project pass the workflow we can achieve a good quality in the software factory.
Besides, we can automatize every deploy done to each environment.
Attached a diagram with the proposal workflow.
The workflow contains the following stages:
Checkout the code
Compile the code
Execute tests
Quality code analisys, check coverage and OWASP analysis.
Deploy to pre-production environment
User confirmation
Tag the code
Deploy to production environment
Publish to Slack and Jira
Workflow implementation
I think the version 2 of Jenkins is the most appropiate tool for this job, since they have incorporated a new feature to create “pipelines” with code. These pipelines are groovy scripts.
So I got down to work and started working with Jenkins Pipeline not without giving me the some headache.
I chose Maven as the main tool since with different plugins it allows me to carry out most of the actions of the workflow. I could also have used the Jenkins plugins but they are not updated to support the pipeline.
Attached code:
With Jenkins we can automate a lot of task that developer would have to do instead of develop code, in addition those task are prone to failures, with which we remove that possibility. We can also impose a series of quality rules in the code that have to be fulfilled if we want to deploy a new version.
Below is shown a real execution of the pipeline in Jenkin. Our Jenkins has installed the Blue Ocen Plugin. This plugins improve the Jenkins UI.
Next Steps:
Docker integration. Execute stages in docker containers.
Ansible integration. Deploy to multiple servers with one command.
Jira Api Rest. Publish in Jira the release notes.
If you have any doubt, please contact me or leave a comment and so I can help anybody interested in Jenkins pipeline :)