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

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.

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 single pipeline for multiple projects without multiple azure-pipelines.yml files

We have an Azure DevOps Pipeline defined as a template in a .yml file, and would like to use this to build 100+ projects.
There is zero parameterization to do, and the template essentially just runs against the project repo as-is.
Normally, we would just go into each of those project repos and create an azure-pipelines.yml file and reference the template pipeline, easy.
However, I would like to know if we can avoid creating these azure-pipelines.yml in each of the 100+ project repos. Is there some way to just run the template against 100+ repos, but as separate pipelines?
No.
YAML pipelines are based upon the YAML being stored in the application's repo, as code, alongside the application code. You can pull in templates from other repos, but you can't have one pipeline that is automatically valid for any repo.
Trying to use one template to build 100+ applications without the possibility of pinning the template to a specific version on an application by application basis is setting yourself up for a nightmare at some point in the future, when the template changes in such a way that it's no longer valid for a subset of your 100 applications.

Run automated tests from Azure Test Plans using a YAML pipeline

Until recently I ran Selenium automated tests from the Azure Test Plans using a YAML pipeline for the Build part and a classic Release Definition for the Release part.
Now, the organization I work in does not allow the use of classic Release Definitions from Azure DevOps.
So I extended my YAML Build Pipeline with stages for running my automated tests on different environments.
But I also want to make use of the Azure Test Plans for running my tests.
My problem is that when I want to run a test from my Test Plan, the only possibility for selecting a Release pipeline is the classic Release Definition I have created.
Is there any possibility to trigger the run of my automated tests from the Azure Test Plans, but to use a YAML pipeline when selecting the Stage.
Thank you!
I tried to edit the settings of my Test Plan, but in order to select a Stage, I have to select a Release Pipeline, and the only options are the ones existing in the Pipelines -> Releases windows of Azure DevOps

Azure Pipelines maintaining multiple countries / environments

We are planning to implement CI/CD for our project. In summary, our setup is the following:
Code Repository (contains solution and project files)
Config Repository (contains .config files for different countries)
Aside from having multiple environments, we also have instances in multiple countries. Sample below:
Country 1
Dev
QA
Prod
Country 2
Dev
QA
Prod
I understand that Azure Release Pipelines can have multiple Stages (Dev, QA, Prod) and Variables that can be used for deployment. Then we can have a 1 Release Pipeline for each country.
What I am having difficulty is the Config Repository. Sometimes, developers may need to update a specific config file for a Country for a specific environment.
The only solution I can think of is trigger a release pipeline with this again, but just to replace the Web.config on IIS in the VM.
However, this is not good, because if developers only update Code Repository, any changes from Config Repository will be overwritten.
Any suggestions on how to automate multiple countries / environments with pipelines?
Thank you
Hi you can use Azure DevOps Environments to target environment strategy (in your case country and Dev/QA/Prod)
Normal practice shouldn't using repository for .config and any settings files.
you can also consider using Secure files for Azure Pipeline or inline script (within your environment deplyonce)
you can start exploring that Azure Pipeline Environment to understand it and YAML and how can it apply to you Multi-Stage YAML.

Multiple Release Pipelines

Need your inputs as I am new to Azure DevOps. Is it possible to have multiple release pipeline & single build pipeline in Azure? As per the best practices, if within a single solution, there are multiple projects, it's best to have single build pipeline per project & then create corresponding release pipelines. Now information I have received from developers, their application is so integrated that it is very difficult to seperate out projects to their individual solutions. They are suggesting to create multiple release pipelines for windows services & web services for various projects.
is it still possible?
Is it possible to have multiple release pipeline & single build pipeline in Azure?
The answer is yes.
There is no one-to-one correspondence between the build pipeline and the release pipeline. We can have multiple release pipeline & single build pipeline, or have multiple build pipeline & single release pipeline. It all depends on your needs.
But when we are dealing with these special situations, we need to be very clear about the output of the build pipeline and the generation of artifacts or the input of the release pipeline and the deployment of artifacts, otherwise it is easy to cause confusion.
For your situation, I have create a simple sample to explain the process.
In the build pipeline, I have two projects in my build pipeline. Build the solution (or all projects) by Visual Studio build task, then we need create two artifacts for each projects:
Then publish the build artifacts with different artifact name:
So we get two artifact for one build pipeline:
Last but not least, we create multiple release pipeline (or we could create multiple stages) for windows services & web services. Release pipeline will download two artifacts from the build pipeline, We only need to deploy the artifacts of the corresponding project to the corresponding server instead of deploying all the artifacts to the server.
For example, if we only deploy the artifact from the project1, we just need to select the artifact, like:
The artifact source should be:
$(System.ArtifactsDirectory)\_TestBuild\drop1