Developing for tomorrow, one dream at a time
For the second article in the series, I thought I would discuss parts of the CICD pipeline. Firstly, my predecessor (Guy Gershoni), had already set up Gitblit, Jenkins, and minio in docker stacks. He had also created 1 or 2 working examples, which I extended for production uses, and I will be discussing this.
Probably the best place to start is with our git platform. Guy, and our boss had decided to go with Gitblit for our git repository. One of the unique approaches Gitblit possesses is its approach to merge requests, or pull requests. Gitblit’s version is called a ticket, which is essentially a branch with a special tag. For a deeper explanation of what gitblit tickets are, please read the following: GitBlit Tickets. The Docker image we used in our git stack can be found at the following URL on Dockerhub.
Our Jenkins implementation is a custom build of the Jenkins docker container, which gives Jenkins the ability to run docker containers. Following the instructions found here, will give you the beginning of a Jenkins Docker setup that will allow you to execute jobs inside Docker containers in your pipeline.
We currently configure our Jenkins Projects to poll the related gitblit repo every minute for new commits. As our git repo and Jenkins system reside internally on our network, the fact that we are polling git every minute from Jenkins, and not using a webhook is not too much of an issue, as we don’t have too many Jenkins projects at this time. At the time of writing, I do believe Gitblit can handle webhooks, and it will be something I will be investigating in the future.
Our Jenkins projects are configured to watch a certain branch on the git repo. When the polling notices a new commit on the nominated branch, it then processes our Jenkins Pipeline script. Depending on the project, if it is a Java application, the pipeline script executes ANT on the project, to compile the code into jars. The pipeline script then, using fpm, builds our rpm file for deployment. The execution of the ANT build and the creation of the rpm are done in their own docker containers, so we don’t have dependancy issues between packages. This is the reason for the custom Jenkins implementation.
Once Jenkins builds the RPM, it then connects to our minio server and copies the created RPM. One of the functions in Minio that we use, is it’s webhook system. We have a webhook attached to each of our buckets (1 for testing and 1 for production for example), that when a new file is copied into the bucket, it refreshes the RPM repository index. On the other side of Minio, we have a webserver that hosts the directory out as our RPM repository for our client systems to grab their RPM from.
Source Code for jenkins docker and a pipeline example: github
Important lessons I learned: