Maintenance of multiple environments is becoming very hectic these days. Hence the concept of containerisation dominates the world with its ease of scaling and elasticity factors.
With Docker’s capability of virtualisation, it is now possible to create environments like Dev, QA, UAT on the go and deploy, test and dispose of with no manual interventions. This way of implementation is the best example of Continuous Delivery and Deployment.
In this strategy, everything starts and ends with Jenkins.
Jenkins Job 1 – Initial Setup: A Jenkins job to perform the act of pulling the code from the repository like GitHub or BitBucket and initialise the build to find any known build errors
Jenkins Job 2 – Dev Container Creator: This job will be a downstream of Jenkins Job 1, which will be creating and configuring the image of an application server for the development environment.
Jenkins Job 3 – Deploy and Unit Tests: Once the creation of the Development Container is done, this Jenkins job will eventually deploy the web application and run the unit tests
Jenkins Job 4 – QA Container Creator: This job should be triggered only when all the unit tests are passing. In this job, we will spin up an image of another docker container with the web server in it, but now with a different port number
Jenkins Job 5 – Deploy and Smoke Tests: Once the creation of the QA Container is done, this Jenkins job will eventually deploy the web application and run the smoke tests
Jenkins Job 6 – Regression Tests: Regression automated tests should be called once the smoke tests are passing. Note that the smoke tests should contain the basic functionalities to be tested
Jenkins Job 7 – UAT Container Creator: This job should be triggered only when all the Regression tests are passing. In this job, we will spin up an image of another docker container with the web server in it with a different port number
Jenkins Job 8 – Deploy and Smoke Tests: Once the creation of the UAT Container is done, this Jenkins job will deploy the web application and run the smoke tests again to check whether the basic functionalities work without any breakage
Jenkins Job 9 – Performance Test Scripts: UAT environment is always dedicated to Performance testers where automated performance test scripts are executed and the results are published
Jenkins Job 10 – Production Deployment: This is an optional job to be integrated with Continuous Delivery point of view. Some organisations might have a specific time to move the code to the production environment. In that case, have this as a separate Jenkins job out of the CD pipeline. In case if you want to move the code to prod environment, make this as a downstream job for Jenkins Job 9 and deploy the code
Jenkins Job 11 – Tear Down Job: Thus job eventually disposes or terminates the instances of Dev, QA and UAT environments (docker images) after the production deployment happens successfully
It is always a best practice to send appropriate notifications via email to the developers and any other stakeholders to notify the current stage from the pipeline.
Also, terminate the Jenkins job if there are any failures and execute the Jenkins Job 11, before quitting the pipeline.