2
votes

I was playing with Azure Build pipelines. My Goal was that Developer should be able to create a Build Pipeline for their project. But he/she will not be creating it via Azure DevOps console, instead, they would Trigger a build job which would create Build pipelines for them. I was able to achieve it by having a common Template.json and invoking it using PowerShell scripts.

But I see that we can create a build pipeline by having an azure-pipelines.yaml in our repo. So I have two issues which I am struggling to face.

  1. An Azure pipeline job that will read the azure-pipelines.yaml and create a build pipeline for the user.
  2. Read the Azure-pipelines.yaml file which is kept inside the sub directories in the repo.

Appreciate your help.

Thanks.

2
What about having a basic git repo for an application (or a repo for each type of app) where you could have a basic azure-pipelines.yaml?Liviu Costea
@LiviuCostea yes . That solves the issue . But our hands are tied. We cannot change the repo structureBalakumar Ezhilmaran

2 Answers

1
votes

Resolved :)

  1. Created a powershell script which uses the json file which was exported from a existing pipeline job.
  2. The JSON file will be using the azure-pipelines.yml file to create the tasks.
  3. The Powershell script updates the json file and makes a rest call to create a pipeline.

The documentation is very poor . I was unable to find documentation on creation of pipeline through code . I Checked the Request body while saving the pipeline from which I was able to get the details to refer the yml file .

0
votes

You can use AzurePipelinesPS to Get-APBuildDefinition and Publish-APBuildDefinition.

The functions use return and post json objects. I modify the json templates with tokens and update them are needed. Format-APTemplate will replace the tokens in the json template.

There are functions for release pipelines as well; Get-APReleaseDefinition and Publish-APReleaseDefinition.