In a world filled with automation and DevOps tooling, the top contender is Continuous Integration and Continuous Delivery (CICD). CICD provides the ability to not only automate the shipment of software, but to do it in a reliable and efficient way without risking quality engineering. With the power of a good CICD platform and app, you can ensure that end-users receive continuous value.
When working with a CICD platform, the main goal is to build production-ready releases for code, and in this guide you will learn just that. You will perform a real-world example approach on how to create a development pipeline in Azure DevOps. Since the pipeline is for development purposes, you will learn how to create one stage for Dev. After the stage is created, you will create a build pipeline to package up an app and turn the code into an artifact. After the code is turned into an artifact, you will have an app ready to deploy for a release pipeline.
To follow along with this blog post you should ensure that you have any type of code committed to a GitHub repository that you have access to. This blog post will use the C# code found in my GitHub repository here.
In this section, you will take a hands-on approach at creating a development build pipeline in Azure DevOps to package up code into an artifact that is ready to be shipped to end-users. In some organizations, the build pipeline may also be called the Continuous Integration (CI) pipeline. The purpose of CI is to build and test code every time a developer commits changes to version control. With that typically comes building an artifact, which is why you may hear "build pipeline" and "CI pipeline" used interchangeably.
Before creating the artifact, the initial pipeline needs to be created. In this portion of the guide, you will start the creation of the pipeline.
Log into the Azure DevOps portal.
Go to Pipelines —> Pipelines to access the pipelines pane.
Within the pipelines pane, click the blue New pipeline button.
Under the Where is your code? section, choose GitHub. This allows you to select the code that you want to build and turn into an artifact.
For this example, on the Select a repository page the CloudDevWebBoilterPlate repository was chosen, which is the repository linked in the prerequisites section.
In the Configure your pipeline section, choose Starter pipeline. The starter pipeline allows you to create a pipeline from scratch to add in any tasks that suit your needs in building the app.
On the Review your pipeline YAML page, remove lines 13-19 so the code looks like the screenshot below. These linesaren't needed because they're pseudocode.
Click the Show assistant button as shown in the screenshot below to add the two tasks that are needed to create the build pipeline.
The two tasks that you will need to add are:
Copy files - This task copies the code from the linked GitHub repository and stores it in the pipeline to be used in the next task. The target folder is a predefined Azure DevOps variable which is a local path on the pipeline agent.
Copy filestask and creates an artifact out of the copied code. The path to publish uses the same predefined variable as shown in the
Copy filestask because that's where the code was copied to. The
Publish build artifactstask needs to look in that location to create an artifact out of the code.
Click the blue Add button on both tasks and you should see code similar to the below.
1 trigger: 2 - master 3 4 pool: 5 vmImage: 'ubuntu-latest' 6 7 steps: 8 - task: [email protected] 9 inputs: 10 SourceFolder: 'web' 11 Contents: '**' 12 TargetFolder: '$(Build.ArtifactStagingDirectory)' 13 - task: [email protected] 14 inputs: 15 PathtoPublish: '$(Build.ArtifactStagingDirectory)' 16 ArtifactName: 'drop' 17 publishLocation: 'Container'
Click the blue Save and run button to run the build pipeline.
The code for the YAML pipeline creates a
azure-pipelines.yml file that needs to be stored where the code that is being built and turned into an artifact exists. On the Save and run page, put in a commit message or leave the default and commit directly to master, because the existing code is linked in the prerequisites section of the GitHub repository .
Click the blue Job button so you can see the code being built and turned into an artifact.
Congratulations! You have successfully created and deployed a build pipeline.
In this guide, you took a hands-on approach to create a build pipeline. You started off by initializing the pipeline and creating the first development stage. Following that, you pointed the pipeline to the code in GitHub that was going to be built and turned it into an artifact in the pipeline. Finally, you created the new type of pipeline in Azure DevOps, called YAML pipelines, to deploy the copy and publish tasks to create an artifact out of the code.