56

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.

Lam Le
  • 1,489
  • 3
  • 14
  • 31

4 Answers4

96

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

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
  • 1
    I'm using a feature branch. So naturally, I want to test the tasks before setting triggers. I reckon that I can set a trigger in YAML to that feature branch for testing and before merging back to master, I will switch to master branch. About the secone part. I can't find that "repo build page". May you be a bit specific? Thanks. – Lam Le Nov 27 '19 at 09:55
  • @LamLe do you have a yml file for the master branch? – Shayki Abramczyk Nov 27 '19 at 10:04
  • 1
    No, not yet. I branched out a new branch, (let's say `abc`). I created a yml file on `abc` branch. Now I want to create a new build pipeline from it, especially an option with the yml editor of Azure DevOps (I edited the question). As I know there is a task in classic editor that lets me run a yml file in my repository. But it does not have any editor on the website. – Lam Le Nov 27 '19 at 10:10
  • 2
    Aah. Bingo! Amazing. I wonder why I missed this one last option. Thank you very much. – Lam Le Nov 27 '19 at 10:19
  • I could create the pipeline as suggested in this answer but I am unable to give a name. It takes the name of the branch where I create it. Is it a limitation or I am missing something? – Lupa Apr 22 '22 at 21:20
  • Found a solution: To rename the pipeline created from existing yaml, just "Rename/move" it. Go to the pipeline page and then click the dots button to the right of "Run pipeline" and select "Rename/move". – Lupa Apr 22 '22 at 22:22
19

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.

Mobiletainment
  • 22,201
  • 9
  • 82
  • 98
  • 4
    Thank you! At the time I asked the question, the UI wasn't this clear. The option "existing Azure Pipelines YAML" wasn't clear as well. I'm glad Microsoft has improved this UX. Anyways, thanks! – Lam Le Sep 18 '20 at 17:40
9

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.

Triamus
  • 2,415
  • 5
  • 27
  • 37
5

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)

Josh Hulbert
  • 51
  • 1
  • 1