Unable to export the build pipeline which is created by YAML on Azure DevOps - 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.

Related

Can I create Release pipeline (CD) in Azure DevOps directly using YAML?

I need to create a release pipeline (CD) without creating a CI pipeline. I will use artifacts from GitHub. Can I create the CD using YAML or it is like I need to create CI with YAML and CD can not be created directly using YAML ?
You can't create Release classic pipeline using YAML. Your only option is the editor. But YAML has something different (which in the future can replace Release pipelines - this is my personal opinion). It is job deployments. Please take a look here.

Is there a json schema file for Azure Devops Pipelines

I have exported my pipeline from Azure Devops. This results in a json file I can import to create a new build definition. Is there a schema definition that defines this file. I would like to edit it (using VS) and a schema serve as documentation-instead of hacking it.
There's yamlschema endpoint in Azure DevOps REST API that returns schema for YAML pipeline:
GET https://dev.azure.com/{organization}/_apis/distributedtask/yamlschema?api-version=5.1
Seems like this is where azure pipelines extension takes it from.
I use vscode and I'm trying out the yaml extension. However, I found there is also an azure pipeline extension, but the yaml extension is more popular.
In order for me to get azure pipelines working on the yaml extension, I was able to find the json schema that azure pipelines used here. I referenced using the raw file, but there are still bugs here and there.
On the https://www.schemastore.org/json/ there are a lot of schemas, and especially for Azure Devops Pipelines
The file tasks.schema.json seems a schema definition for the tasks in pipeline. And this repo(https://github.com/microsoft/azure-pipelines-tasks) includes examples on how we write tasks which will help you write other tasks which can be uploaded to your account or server.

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

All Build and Release Definition Export At Once?

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.

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.