Is there a json schema file for Azure Devops Pipelines - azure-devops

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.

Related

is it possible to create azure build pipelines using terraform code?

I want to Create Azure Build pipelines using Terraform code, but not able to find any proper documentation on this. Is it possible ?
I tried terraform documentation, expecting some documentation or video guide how to create Azure build pipelines using terraform code
is it possible to create azure build pipelines using terraform code?
The answer is impossible.
Hashicorp doesn't have a terraform provider for Azure DevOps now.
If you check the azurerm provider, only azurerm_data_factory_pipeline is available, no Azure DevOps build pipeline.
You should look at the Azure DevOps provider From Microsoft. It does contain a resource for build definitions but you will need to pass it the path to an existing YAML file, you can't create the YAML from Terraform.
If you have a "templated" YAML then you could create a process that commits the YAML to a repo then use Terraform to set up the definition.

Azure Data Factory CI/CD Improvements integrated with DevOps

I've been reading the following link.
https://learn.microsoft.com/en-us/azure/data-factory/continuous-integration-delivery-improvements
It mentions using npm to build the Data Factory ARM templates and use the resulting artefact to deploy to UAT/Prod etc instead of using the adf_publish branch.
Has anyone got a sample Yaml file that does this?
Also, how would you handle overriding the ARM Template Parameters Json file for changing over parameterization such as the Environments Key Vault etc e.g. Dev-KV -> UAT-KV, Prod-KV
This is what I did. I followed this article to get my yaml file setup, there is a github repo in the article that has all of this persons code.
Azure Data Factory CI-CD made simple: Building and deploying ARM templates with Azure DevOps YAML Pipelines
Then I used Global parameters and referenced those everywhere in my pipelines. Here is a ref for that: Global parameters in Azure Data Factory
And finally, I used the overrideParameters option in my yaml pipeline to deploy the correct version of the parameter to the correct environment. Here is a ref for that: ADF Release - Set global params during deployment
Hope that helps!

How to Batch Convert Azure Pipelines YAML to Github Actions YAML?

I have Azure YAML pipelines that have been created long back and I am now looking into migrating my existing devops solutions form Azure to Github Actions.
How do I approach migrating / translating existing pipelines from Azure DevOps to Github Actions?
Manually translating each ADO Pipeline is not something that would be consider a feasible solution for the number of pipelines I have.
Reference Links:
Azure DevOps Pipelines: https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/?view=azure-pipelines
Github Actions: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
Simply put: I need to convert my existing ADO pipelines to Github Actions
I am thinking of building a tool to serve this purpose of converting Azure DevOps pipelines to Github Actions but need ideas on how to approach this problem.
From Leo Liu's answer, May 2022:
I am afraid there is no such out of box extension or tool to batch Convert Azure Pipelines YAML to Github Actions YAML at this moment.
Update:
Introducing GitHub Actions Importer (Nov. 2022)
We’ve launched a public preview of GitHub Actions Importer, which helps you forecast, plan, and automate migrations from your current CI/CD tool to GitHub Actions.
Doing individual migrations is relatively easy in isolation.
However, for those that have a large and established CI/CD footprint, having tooling available to assist with migrations is key to their ability to adopt Actions at scale.
In the time that we’ve been developing and using GitHub Actions Importer in its private preview form, we’ve encountered numerous customers that have thousands of pipelines—even in excess of 15K—in their legacy environments that need to be migrated.
GitHub Actions Importer is designed to help when manual migration is not feasible, such as when users have a large number of teams that depend on hundreds or thousands of workflows.
To learn more, see Automating migrations with GitHub Actions Importer and the announcement post on the GitHub blog.
Sign up here to request access to the public preview.
So check it out: it does list Azure DevOps in its Supported CI platforms.
How to Batch Convert Azure Pipelines YAML to Github Actions YAML?
I am afraid there is no such out of box extension or tool to batch Convert Azure Pipelines YAML to Github Actions YAML at this moment.
There is a tool to make migrations between Azure Pipelines YAML and GitHub Actions YAML easier for one YAML file at a time:
Convert Azure Pipelines YAML to GitHub Actions YAML
But the tool for batch convert doesn't seem to exist yet.

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.