As a DevOps engineer I am partially involved in migration of CicrleCI workflows to Jenkins on Kubernetes. In this article, I will try to share my knowledge on this topic and I hope it will be useful to you.
Let’s start.
What is CircleCi?
CI/CD platform lets teams build and deliver great software, quickly and at scale, either in the cloud or on a self-hosted server.
Jenkins is a self-contained, open source automation server which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software.
Jenkins plugin to run dynamic agents in a Kubernetes cluster.
The plugin creates a Kubernetes Pod for each agent started, defined by the Docker image to run, and stops it after each build.
Deploy: Publish created package to npmjs.org with ‘npm publish’
Audit: Run security audit with ‘npm run audit’
Defined Workflows
Build’ stage always runs first.
‘Deploy’ stage depends on ‘build’ stage, meaning it will run after ‘build’ stage completed. Also, deploy branch runs only for branch starting with ‘publish-v’.
‘Audit’ stage depends on ‘build’ stage, it will run after ‘build’ and only for the ‘master’ branch.
2nd and 3rd may run in parallel after the 1st stage is finished.
Let’s create this flow on Jenkins with multibranch pipeline
Definition of pod template: build-pod.yaml
Jenkinsfile
To simplify things, I am not running ‘Deploy’ and ‘Audit’ stages in parallel, which is not correct, so let’s fix that