Use a YAML template as a task/step/job/stage in classic pipelines [duplicate] - azure-devops

This question already has answers here:
Migrating existing (entire) Azure DevOps pipeline to YAML based pipelines (in bulk)
(3 answers)
Closed 2 years ago.
I have a number of existing build and release pipelines defined using the classic interface, but I'm switching over to using the newer YAML pipelines and templates. Converting the existing classic pipelines to YAML pipelines would be too much work, but I would like to define any new pipelines using YAML pipelines and templates. Would there be a way to still use the newly defined YAML templates from the existing classic pipelines if necessary?
Edit: to clarify, this is not a question about how to bulk migrate classic pipelines to YAML, but about using YAML templates in classic pipelines.

No. This is not possible. In terms of moving from Classic to YAML the Azure DevOps team works on tool which should help converting this. However, this is not ready yet. I check status of the task and it was moved again to planned.
Description of above mentioned task:
We'll add a migration tool to help convert your classic build pipelines to YAML. While there is a gesture to generate a snippet of YAML for selected tasks in the classic editor, there has been enough feedback from customers calling for a more complete experience to support this migration.

In the upcoming Sprint 178-Update, we will introduce a new "export to YAML" feature for designer build pipelines. Save your pipeline definition, then find "Export to YAML" on the ... menu.
The new full export replaces the "View as YAML" function found in the build editor. The older function was incomplete as it could only inspect what the web UI knew about the build, which sometimes led to incorrect YAML. The new feature takes into account exactly how the pipeline will be processed and has full fidelity with the designer pipeline.
Currently azure devops service is updated to Sprint-177.

No, but you can find "View YAML" on the job or task section to simplify the migration process:

Related

Is there a pattern for including Release Pipelines in Azure Dev Ops via Source Control and Automation?

Our team uses Azure Dev Ops for our source control and release pipelines. The release pipelines are not included in our source control and are created through ADO UI. These can be very complex; I exported one release and it was 7500 lines of json. I would like these pipeline definitions to be in the same source control as our source code for easy maintenance and review.
I see that there are tools for exporting the pipeline definition to json and an option in the UI to create a pipeline by importing json. Is there a pattern to use automation to leverage these import/export functions and have a pipeline that is updated based on the definition in my repo?
We are currently just using the UI to update the pipelines without any additional version control or review controls. I'm expecting some functionality like GitHub Actions where the pipeline definition is contained within the repo and automation picks up the files.
If you want to version control your pipelines, I suggest that you start using the yaml pipelines that exist in Azure Devops.
These can handle both build and release pipelines. The "Releases" tab in the GUI becomes obsolete, as all pipelines (both build and release) instead show up in the "Pipelines" tab. For release pipelines, use the deployment job type, which gives you access to automatic artifact handling and environment management.
Edit: So to answer the actual question, I do not know any way to version control the GUI (classic) pipelines. My strong recommendation is to migrate to yaml pipelines.

Azure DevOps: Why does new pipeline commit the yaml file to default branch

I created a new pipeline in Azure DevOps, and created a new branch for it.
As a result, DevOps automatically committed the YAML file for the new pipeline to my 'development' branch.
None of the other pipelines I've created have YAML files committed into the repo...
Why does it do this?
Do we have to keep the YAML file there?
It has nothing to do with the source code of the application, so doesn't seem to make sense why its stored there.
YAML is code for how your application is deployed, thus it is part of the source code. By putting it under source control it can keep track of version changes and any additional changes to parameters or variables that are determined or inserted in the build process.
This is opposed to the older ways of doing things where it was updated via UI and not source control and did not have peer reviews, branching merging, and additional polices that can be applied.
This on top of the the YAML Pipelines for Releases going GA the other week will make YAML under a repo even more powerful as the YAMLs will not only build but also release code.
In Azure Devops Service we define pipelines using the YAML syntax or through the user interface (Classic). So there're two kinds of pipelines, Yaml pipelines and Classic UI(Classic build and release) pipelines.
None of the other pipelines I've created have YAML files committed
into the repo...
Why does it do this?
It's expected behavior when defining pipelines using Yaml syntax: The pipeline is versioned with your code. It follows the same branching structure.
And one advantage for this is: A change to the build process might cause a break or result in an unexpected outcome. Because the change is in version control with the rest of your codebase, you can more easily identify the issue.
To sum up, the yaml pipeline will be added into version control and it's by-design behavior. If you don't want this behavior, you can feel free to use Classic Build and Classic Release pipelines. It's also a good choice! About the differences between these formats you can check Feature availability. Hope it helps :)

Cloning an Azure Devops yaml Pipeline

Azure Devops pipelines provide a clone functionality. This is super useful functionality for scaffolding pipelines. My yaml pipelines have a lot of variables, and it's difficult and error prone to reassign all of these variables from scratch.
The Azure Devops UI updated in the last week or so, and there doesn't seem to be an option to clone yaml pipelines anymore. Classic pipelines still have the clone option.
Can anyone figure out how to clone a yaml pipeline with the new UI?
Hmm I haven't used the clone feature, but have you investigated using variable groups or variable templates to make your life easier? You can link a variable group to Azure Key Vault to facilitate secrets.
I've never used a cloning option in YAML. But I wouldn't use so many Azure DevOps variables which were created in the UI. You have multiple options here:
Store the variables in your YAML file (not for secrets)
Store the variables in a YAML template (not for secrets)
Store the variables in a variable group (use Azure Key Vault or the Secure flag for secrets)
The variable group can be linked to multiple pipelines. But there is currently no scope available. So, if you have multiple environments, you have to name it like "myvariablegroup-dev", "myvariablegroup-prod". Hopefully, this feature to attach a variable group to an environment is coming in the near feature.
1,You can disable the multi-stage pipelines feature in preview features
On the top right corner of the page click the user profile and choose Preview features
Then disable the Multi-stage pipelines. Then you will see the clone option appear again.
2,The other workaround is to create a new pipeline and choose to use the Existing Azure PipelineS Yaml file while following the wizard. (which has the same effect with cloning yaml, they use the same azure-pipelines.yml file)
Then choose the same yaml file with the original pipeline.

How do I edit view and edit the YAML file for the Release Pipeline in Azure Dev Ops?

I've successfully built my code on Azure Dev Ops by modifying the pipeline YAML file, but I have been unable to successfully deploy the artifact to my IIS Server. The only way to create a deployment is by using its unpleasant UI.
I've read that by turning on a multi-pipelines preview feature, you can view and edit the YAML file. Unfortunately, it doesn't work. You can edit the build scripts, but not the release ones. I tried to add deployment tasks in the main pipeline YAML file, but it neither executes or shows up in the releases section.
The "Release" section in Azure DevOps is still only in the UI, you can't use it in YAML.
But when you enable the multi-stage pipelines you can use the "build" YAML pipelines also to deploy your app (you can see that no "Builds" tab anymore, there is "Pipelines").
The downside is that you don't have all the features that exist in the release, like approvals, gates, etc. but you can see in the roadmap that Microsoft work on it and the features will be available also in the YAML.
You can check this article on how to use the multi-stage YAML for build & deployment.
Another good tutorial from Microsoft available here.

How to use Environments feature with pipeline release stage

I have defined a release pipeline using the classic view, now I'm wondering if it's possible to connect an Azure pipeline Environment with and existing stage in the release pipeline. If it's possible how can it be done?
It seems you refer to the new Environment in the preview, the features there include:
Traceability of commits and work items
Deployment history down to the individual resource
Deeper diagnostics, and (soon) approvals and checks etc
From this document,it seems that the environment feature can only be used in yaml . The sample given are all in yaml. It should be currently not supported in the classic view.
You can also refer to the Building your first multi-stage pipeline with environments part of this blog .