Call a release build from REST api in Azure - azure-devops

I want to call the Azure Devops to create a new release from one of my Release Pipelines.
I have been looking for different calls but its either to create the pipeline or build artifacts.
Is there a way to call a release pipeline from Azure API?

I did it with the next endpoint: https://learn.microsoft.com/en-us/rest/api/azure/devops/build/Builds/Queue?view=azure-devops-rest-5.0&viewFallbackFrom=vsts-rest-4.1
I was using a wrong body for the endpoint. With the example from the documentation it worked.

Related

Renaming Azure Devops Build and Release pipeline through REST API

trying to rename the pipelines build and release through REST API, I have gone through the official Microsoft documentation but didn't find any API's for this task. Did i miss any or we have such API's where by using build id/build name we can rename the pipeline
have you tried to make the change in the azure release page and look at the request that is being sent in the dev tools network tab? A couple of months ago I was able to learn how to retrieve some information that I was looking for by doing that.
Best regards.
You could use Definitions-Get API to retrieve the requested body by pipeline definition ID.
Copy the response as body and use Definitions-Update to rename the pipeline. Update the pipeline name of this revision.
Check the DevOps UI output.
The above workflow also applies to release pipeline, your need to change the REST API.
Using Releases-Get release to get the latest revision and using Releases - Update Release to rename it

How to add dependency between two release pipeline Azure DevOps

I have a scenario that i want to create a dependency in Release pipelines that once one pipeline completes its task then the next release pipeline should be triggered.
How can I achieve it.
How to add dependency between two release pipeline Azure DevOps
You could use the extension Trigger Azure DevOps Pipeline:
Trigger Azure DevOps Pipeline is an extension for triggering a Azure
DevOps Build or Release Pipeline.
Depending on your choice in the task, it will trigger a build or a
release pipeline.
To use the extension, an Azure DevOps API endpoint needs to be
created. The token used in the endpoint should be Personal Access
Token.

Integrating Service Now with Azure Devops

i am trying to have an integration between service now and azure devops .
If any one can answer below question it be much appreciated.
How to trigger Azure DevOps pipeline automatically on Approving the Change Request in ServiceNow ?
I am approaching with rest API method to call AzureDevops from servicenow plateform.
Does anyone has done something similar and can help me here by listing steps to do so?
You need to create a Service Connection to you ServiceNow instance and then add a Gate in your Release pipeline which creates the Change Request in ServiceNow and then waits for it's status to change.
This provides a good guide - https://learn.microsoft.com/en-us/azure/devops/pipelines/release/approvals/servicenow?view=azure-devops and your gate will end up looking something like this:
You can also use an existing CR but then you'll need a way to supply that to the pipeline on creation of the release.
In the azure devops, we can Install and configure ServiceNow DevOps extension for Azure DevOps to send build and release notifications from your Azure pipeline to ServiceNow DevOps application.
For more details, you can refer this doc: Azure DevOps integration with DevOps

How to get list of release pipeline name in Azure DevOps using rest api

I am working on script to list all release pipeline names
I found this rest api in Microsoft docs -
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=6.0
This lists all releases for each release pipeline
Using following pipelines rest api I can get count and info of only build pipelines -
GET https://dev.azure.com/{organization}/{project}/_apis/pipelines?api-version=6.0-preview.1
Is there similar rest api available like pipeline api to get count and info of all release pipelines (not all releases for each release pipeline)
or Is there way to get all pipelines builds and releases using single rest api ?
You need to use Definitions - List api to get the count and info of all release pipelines.
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=6.1-preview.4
There is not a single rest api to get all pipelines builds and releases. If you want to get all pipeline builds. You need to use Builds - List api. And Releases - List api for pipeline releases

How to create new build pipeline using Azure DevOps REST API?

I'm trying to create new build pipeline through programmatically. I'm looking for Azure DevOps REST API for this action. I didn't get the proper examples for creating the pipeline using REST API.
Please advise.
How to create new build pipeline using Azure DevOps REST API?
To create the new build pipeline, we could use the REST API Definitions - Create:
POST https://dev.azure.com/{organization}/{project}/_apis/build/definitions?api-version=5.0
But we need provide too much information in the Request Body, this will be a big project and error-prone. That also the reason why the document not provide a sample Request Body there.
To resolve this issue, usually we would use the REST API Definitions - Get to get the Response Body from the template pipeline:
GET https://dev.azure.com/{organization}/{project}/_apis/build/definitions/{definitionId}?api-version=5.0
Then we just need to update the corresponding properties by modifying the Response Body.
Now, we get the new Request Body for the new pipeline, we could use it with REST API Definitions - Create to create a new pipeline.
You could check this thread for some more details.
Update:
After creating the build definition, Will it create
azure-pipelines.yml file and store in the repository like Azure Repos?
No, if you want to create a YAML type build definition using the rest api, it will not create the corresponding yaml file to our repo, because this API Definitions - Create only send the request body to the pipeline does not operate our repo. Currently, it support creating a build definition that links to a YAML file within the Git repo. If you want to create the yaml automatically, you could check the REST API Pushes - Create.
This should be where the REST API Definitions - Create needs to be improved to support the YAML pipeline. You could add your request for this feature on our UserVoice site (https://developercommunity.visualstudio.com/content/idea/post.html?space=21 ), which is our main forum for product suggestions. Thank you for helping us build a better Azure DevOps:
Hope this helps.