Pushing your builds down the pipe the right way !
A big part of DEVOPS is being able to understand what the benefits of pipelines are and the best way to create them.
Pipelines is a key feature of both CI (Continuous Integration) and CD (Continuous Deployment), as it is the mechanism that allows you to integrate and deploy code into your cloud or on-prem environments.
A pipeline’s goal is to take newly checked in code to a repository, perform tests and checks on that code to ensure it conforms to best practices and doesn’t cause issues when released into an environment.
Creating a pipeline can be done via a GUI such as in Azure Devops, but if you work in or want to get into DEVOPS the best practice solution is to know how to deploy pipelines via YAML code, as it gives you more flexibility and speed. This is because many platforms such as Github Actions, Azure Devops or Jenkins pipeline allow for building pipelines using YAML code, and having this skill allows you to transfer it easily between platforms. (basic knowledge of what YAML is would help)
If you have not written a YAML pipeline before the best way to learn is to break it down into sections like below.
- Stages – A YAML Pipeline can have multiple stages (DEV, Pre-Prod, PROD)
- Jobs – Stages can have multiple jobs to run simultaneously (Deploy code to multiple environments via multiple agents)
- Steps – Jobs can have multiple Steps (Install Terraform, Validate Terraform, Apply Terraform)
Below I have created two pipelines (Github Action & Azure Devops) using YAML code, the pipelines are carrying out the same steps but running on different platforms to show you how similar they are.
Steps:
1. Run when code is push to main branch
2. Create a job and chose an agent that will run the pipeline (Windows or Unix)
3. Steps for the job to carry out (Terraform init, Terraform format, Terraform validate)
As you can see from the above the YAML code is very similar across both platforms.
For further information on this topic see the below link.
Hope this has helped and if you have any questions or anything to add please comment below 🙂