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

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.

Related

Rename "Pipelines" to "Builds" in ADO

How do I customize the "Pipeline" tab in Azure Devps (Image 1) so that it is renamed to "Builds" (Image 2)?
Rename “Pipelines” to “Builds” in ADO
Sorry for any inconvenience.
This behavior is by designed and is not an issue. There is no way to fix it at present.
Azure devops team working on an updated user experience to manage our pipelines. These updates make the pipelines experience modern and consistent with the direction of Azure DevOps.
Moreover, these updates bring together classic build pipelines and multi-stage YAML pipelines into a single experience. It is mobile-friendly and brings various improvements to how you manage your pipelines.
You could check the document Azure DevOps Pipelines – Multi-Stage Pipelines and YAML for Continuous Delivery for some more details.
Since Multi-Stage Pipelines and YAML for Continuous Delivery introduced, Builds are no longer just a single build as before, but also include the CD part. At this time, Builds are no longer suitable as tabs, so they are changed to Pipelines.
This is a modification of product update progress.

What is the natural way to flow the build variables from build to the respective release in Azure DevOps Server 2019 (on prem)?

So, one option is create a file during the build with all the build variables and attach it as an artifact to the build.
Not a big deal, but I am wondering if this is the natural way to do it in Azure DevOps. Maybe there is some feature to enable it easily and I just do not see it?
According to your description, seems you just want to access the Build variables from Release pipeline.
The is no official way to pass variables from Build to Release. What you are doing is the right way.
Alternative, you could use some 3rd-party Azure DevOps extension such as this one--Variable Tools for Azure DevOps Services.
In the "build pipeline" you can create a JSON file using "save
variables". This file needs to be published as artifact or with
existing artifact.
In the "release pipeline" you can restore the variables using "load
variables" from the JSON file.
Also take a look at this similar question here: How to get the variable value in TFS/AzureDevOps from Build to Release Pipeline?

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 :)

Is is possible to inherit a definition of Azure DevOps Pipeline?

I would like to know if there is a mechanisim in Azure DevOps to reuse a definition for Azure DevOps Pipelines.
In my scenario I defined two Azure DevOps (Build) Pipelines to generate the artifacts of my web app; one for staging the other for production. The build definiton is the same in both cases except for two things:
a variable that set the build configuration for the ASP .NET Core (Staging or Release)
the branch that triggers the build (staging or master)
My goal is to avoid duplicated build definition that should be updated in both whenever somehting is updated in the project.
The build definition are in classic mode (no YAML files).
With classic you can create task groups and reuse those. You can select existing build steps and convert them to a task group and then reuse the task group across builds.
This is covered in the following document.
With yaml files you can use templates.

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 .