All Build and Release Definition Export At Once? - azure-devops

Is there a way to export all Build and/or Release Definitions at once in Azure DevOps, instead of doing it one by one ?
Thank you.

You can do that by calling Azure DevOps Pipelines REST API. Start by query all build and release definitions, and iterate on each of the definitions to get the JSON detail of the definition.
But if your build is using YAML file, then the build definition will only container definition of where to search the YAML file and also the variable and trigger settings.

Related

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.

Azure DevOps Keeps Creating Default Build Pipeline

I have a YML file that is a standard template that is called by all my build definitions.
Each of the builds passes parameters into the YML file.
Unfortunately, every now and then, Azure DevOps tries to automatically create a build definition called "--REPO NAME-- CI". I know it's due to the YML template file, but I don't want it to generate that. How do I prevent this Build definition from getting automatically created.

Is it possible to export all build and release definitions from VSTS in a single go?

Is it possible to export all build and release definitions from VSTS in a single go ?
I know it was possible with TFS,
Is it possible to Export TFS 2010 Build Definitions?
Unlike TFS you could use tfpt command line. In Azure DevOps, the simple way is using Rest API to do this.
You could use list build/release definition first, it should return a json file.
Normally, when you import the JSON file, you will get a new build definition.
Besides, if you are using YAML builds which will configure your CI process as code. You could directly copy .yml files.
The release definitions are the same as build.
Well, by the same token, you can use Azure Devops API to export those.
List build definitions
List release definitions

Unable to export the build pipeline which is created by YAML on Azure DevOps

I created a build pipeline on Azure DevOps by using YAML syntax. Now, I would like to export that build pipeline, but the button "Export" the build is unable to click. Does the build pipeline is create by YAML can export to JSON?
Thanks kindly.
This makes no sense really. you have a yaml file, why do you need to export it again? just copy it.

Create Azure pipelines from scripts

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.
An Azure pipeline job that will read the azure-pipelines.yaml and create a build pipeline for the user.
Read the Azure-pipelines.yaml file which is kept inside the sub directories in the repo.
Appreciate your help.
Thanks.
Resolved :)
Created a powershell script which uses the json file which was exported from a existing pipeline job.
The JSON file will be using the azure-pipelines.yml file to create the tasks.
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 .
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.