23
votes

Usually, I create a new build pipeline via the Azure DevOps portal. Then, the editor will take me through the steps of choosing the project source, repository, and template. After that, I will have an option to create a new branch or commit directly to the master branch.

However, this time, I have an existing azure-pipelines.yml file in my branch. I created it with a text editor locally and push this branch to Azure DevOps. I want to attach this file and let Azure Pipelines create and queue a new build. But I can't find any option. The importing build pipeline option only accepts JSON files.

Is it possible to create a new build pipeline from an existing YML file in the repository?

I know I can use the classic editor, which has a step to specify a YML file. But I prefer an option that I can use the YML editor with Task Assistant on the Azure DevOps portal.

Thank you all.

4

4 Answers

47
votes

If you pushed azure-pipelines.yml to a new branch, Azure DevOps detect it automatically, if you have a CI trigger you will see a build start to running.

You can create a new pipeline and specify an existing YAML file:

enter image description here -> Choose you repository.

enter image description here

enter image description here

You can also can go the repo build page (if you already have a build for this repo with other branch) and click Run pipeline and there choose the branch:

enter image description here

enter image description here

7
votes

I found that the easiest method is to navigate to the Repos section, select the repository and click on the Set up Build button there.

Set up Build

You can then select Existing Azure Pipelines YAML file from the options.

6
votes

For me the option starter pipeline or existing azure pipelines yaml file used to show up when creating new pipeline in pipelines UI or when coming from repo UI and select set up build. However, just now Azure Devops immediately jumps to an old yaml file I startet but abandoned. It seems somehow cached. I also tried a different browser but same issue. So my quick workaround is to have an azure-pipelines.yml file in the main directory of the repo and save whatever I need in there. After saving I can change the file pointer to whatever I actually want. Not sure if it's a bug but I don't have time to investigate further.

2
votes

I was running into the same issue. I had a default azure-pipelines.yaml in the root of my repo (hosted in Azure DevOps Repos). It had a few steps in it, but I was working on setting up separate pipelines and templates in a subfolder of the repo. I deleted the pipeline from the main Pipelines view (the yaml file remained in the repo) and when I stepped through the New Pipeline wizard I was not given an option to select an existing pipeline yaml file.

I moved the default azure-pipelines.yaml out of the repo entirely (perhaps just moving it out of the root would have been enough) and then the wizard gave me the list of options (ASP.NET, ASP.NET Core, etc.. ending with Existing Azure Pipelines YAML file)