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

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

Related

What is the natural way to flow the build variables from build to the respective release in Azure DevOps Server 2019 (on prem)?

So, one option is create a file during the build with all the build variables and attach it as an artifact to the build.
Not a big deal, but I am wondering if this is the natural way to do it in Azure DevOps. Maybe there is some feature to enable it easily and I just do not see it?
According to your description, seems you just want to access the Build variables from Release pipeline.
The is no official way to pass variables from Build to Release. What you are doing is the right way.
Alternative, you could use some 3rd-party Azure DevOps extension such as this one--Variable Tools for Azure DevOps Services.
In the "build pipeline" you can create a JSON file using "save
variables". This file needs to be published as artifact or with
existing artifact.
In the "release pipeline" you can restore the variables using "load
variables" from the JSON file.
Also take a look at this similar question here: How to get the variable value in TFS/AzureDevOps from Build to Release Pipeline?

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.

How can I configure a Azure DevOps Release Pipeline to package PowerShell scripts?

I'm new to Azure DevOps and I'm trying to understand how to package a release of a PowerShell script project I'm working on.
I'm previously familiar with GitHub and the manual process for drafting a new release of my project repo. I'm now experimenting with Azure DevOps and what I want to achieve is a similar output to GitHub where my repo of PowerShell scripts are packaged into a zip file which I can publish for release.
I'm not familiar with the pipeline process in Azure DevOps or YAML as a newbie to proper release cycle tools. Previously I've just created scripts and shared them simply as they are or dropped them into a GitHub repo and manually packaged a release. I'm not likely to be turning out large numbers of builds and so have never had to come at this from an automated standpoint which seems to be the way Azure is driving me unless I'm missing something?
It's pretty simple. I prefer to do this using the old-fashing GUI (hint: there is a link when starting a new Build Pipeline that says Use the classic editor), and then convert to YAML after I get my Build Pipeline working.
1) Create your standard Build Pipeline.
2) Add the step to ZIP your files
3) Add properties to that Archive step. Specify the source to zip and target where you want the zip file to end up at.
4) Lastly, convert that single step to a YAML step by clicking in the upper-right corner on the link View YAML.
There are a lot of steps I am leaving out, but I hope this leads you into the right direction.

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.