Cloning, Exporting, and Importing a YAML pipeline
Ankit Ranjan (DevOps Engineer)
Actively Seeking Azure DevOps/Cloud Role | DevOps Engineer | Automating & Reducing Developer Toil | Modernising IAC like Jam on the Bread | Microsoft Certified: Azure Admin Associate | Certified Terraform Associate |
In yesterday's post, we discussed creating a release pipeline using YAMLL. Also, We will learn how to define stages, jobs, and tasks in YAML format
In continuation, this post will guide you on how to clone, export, and import a YAML pipeline from the Azure DevOps portal. These actions are beneficial for saving time when duplicating and adjusting templates.
If you need to create a new Azure pipeline, cloning an existing one is a straightforward option. Here are the steps to perform these tasks:
A. You can export a YAML pipeline by clicking on Edit:
B. Click on … | Download full YAML to download a file:
C. Open a downloaded file and copy and paste it into the new pipeline you created.
In this section, We learned how easy it is to download, copy, and paste a YAML file into a new pipeline. Now, let's explore some of the advantages and drawbacks of using YAML-based pipelines.
YAML template reuse
When working on large projects with multiple applications developed by the same team, it is beneficial to define common templates for reuse, rather than writing everything from scratch for the CI/CD needs of each application. Azure Pipelines supports referencing templates to reuse steps, jobs, and stages, which helps reduce YAML duplication since the applications or deployment processes within the project are consistent. Templates can also include parameters to pass values, allowing customization of the referenced template's behavior.
Consider the following scenario: an Azure pipeline builds the same application twice with two different build configurations in .NET. The file shown in the screenshot defines a parameter, buildConfiguration, and includes three steps: installing the NuGet tool (`NuGetToolInstaller@1`), restoring dependencies with NuGet (`NuGetCommand@2`), and building the solution using the VS build utility (`VSBuild@1`).
In the following example, the same dotnet-build-steps.yml file is used to build the application on two different agents, linux-latest and windows-latest, using identical steps. This setup also allows for the addition of other tasks before and after the build steps:
领英推荐
YAML template expressions
Expressions in Azure Pipelines offer a custom syntax that allows you to dynamically resolve values during runtime, functioning like control logic in your templates. While this chapter won't cover all expression types, it's important to know that you can:
- Evaluate literals and variables
- Use built-in functions (e.g., coalesce, contains, eq, format) for logical conditions or value transformations
- Evaluate job statuses with built-in functions
- Apply conditions to conditionally insert variable values or tasks
- Loop through parameters using the each keyword
- Assess dependencies on previous jobs or stages, including status or output variables
This Week's post covered how to build and release pipelines using YAML. This method is more powerful for developers compared to using the classic editor on the Azure DevOps portal. By saving YAML files in Azure Repos, developers can review each pipeline revision, making the CI/CD process more efficient, transparent, and developer-centric.
You also learned how to handle complex scenarios, reduce YAML duplication, reuse templates, and incorporate dynamic behavior through expressions.
In our upcoming post, we'll explore, deeper into implementing a build and release pipeline using YAML, and learn how to reuse build tasks with Node.js, NPM, .NET, and Docker to build a comprehensive pipeline.
Link For this week's post:
Microsoft Learn Microsoft Azure Microsoft Azure DevOps
Recruitment Head
8 个月*Import Export Executive* – WNPIEE18062024 (International Freight Forwarding Industry) *International Freight Forwarding Company* looking for *Import Export Executive* at *Ahmedabad Gujarat India* ... *Salary* ?30000/- to ?50000/- pm ( *Best in the Industry for Qualified Candidate* ) #whiteicenetwork *For more Details kindly go through this link* https://whiteicenetwork.blogspot.com/2024/06/import-export-executive-wnpiee18062024.html