Renaming Azure Devops Build and Release pipeline through REST API - azure-devops

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

Related

How to access Azure DevOps deploy comments from REST API

I've been able to successfully access all kinds of details around a release in Azure DevOps by leveraging the .NET client libraries (ex: Microsoft.VisualStudio.Services.Release.Client) that wrap the REST API. However, I can't seem to find what the object/property combination is that I would use to retrieve the comments that can be entered when kicking off a deployment to a specific environment.
To be clear, the comments I'm looking for are entered by hovering over an environment of a release and selecting "Deploy". On the right hand side there is a dialog in which comments can be entered and then another "Deploy" button is selected to kickoff the deployment.
Does anyone have any ideas on how these deployment comments can be read by using the Azure DevOps REST APIs or .NET client libraries?
You can use get release history REST API to get deploy comments:
Get https://vsrm.dev.azure.com/{Organization name}/{Project name}/_apis/Release/releases/{Release Id}/history?api-version=6.1-preview.1
Here is my sample:

How can I access the artefact from a pull request for which a build was run?

I'm using azure for a windows app and so I don't really need to go as far as CD as that isn't really relevant. We eventually plan to move to the cloud but for now that is not the case.
I have now got my .net (c#) build running as a build pipeline and I have a develop branch which Pull Requests are used to merge in changes. What I want is for a tester to be able to pick up the build artefact that was created for a particular bug or product backlog item when the pull request was successfully completed. Is this possible without having a Release Pipeline? I don't currently have a subscription that would allow me to create a release pipeline.
How can I access the artefact from a pull request for which a build was run?
Indeed, just as Lucas said, if we are starting from the pull request to solve this problem, it is really difficult. But we could try reverse thinking to start with the build pipeline.
Azure devops provided us some predefined variables, like Build.BuildId, System.PullRequest.PullRequestId.
So, we could use the REST API Pull Requests - Update in the build pipeline to update the comment with the link to the artifact.
PATCH https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}?api-version=5.1
Since the current build is triggered by a pull request, we could use the predefined variable System.PullRequest.PullRequestId to get the pullRequestId directly.
Now, we just need to get the link of the artifact, we could use the Artifacts - Get to get the artifact info:
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName={artifactName}&api-version=4.1
We could get the buildId by the predefined variable Build.BuildId, then we will get the download URL:
So the idea of summing up my solution is to use REST API Pull Requests - Update in the build pipeline to update the comment of the pull request, which contains the download path of the artifact.
Note: You could also add custom conditions in the REST API task in the build pipeline:
and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
So, with this setting, only the build triggered by the pull request will execute this rest api task.
Hope this helps.
The pull request build that you defined can publish artifacts, see this documentation to see how to do it.
Once those artifacts are published, your tested can browse/download them on the build run page (click on header pa> "Related" > click on "#number of artifacts you publish# published").
Alternatively, you could add a task to copy your artifacts to an Azure Blob Storage, but that would require more configuration.
One can find build id with branchName filter :
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=5.0&reasonFilter=pullRequest&definitions={buildDefinitionId}&branchName=refs/pull/{pullRequestId}/merge
Once builder id has been retrieved, get artifact by name :
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName={artifactName}&api-version=6.0

How to publish build artifacts to external organisation using Azure DevOps?

I have an ASP web application that I have building in an Azure DevOps Build Pipeline. That is all fine.
I want an external organisation to be able to define their own Azure DevOps Release Pipeline to consume the build artifacts produced by our Build Pipeline. I need the access of that external organisation to be restricted with some sort of credentials (i.e. I don't want the project to be public to everyone). The external organisation should be able to deploy the latest version.
I thought this would be a relatively simple process using only Azure tools (particularly with reference to Feeds), but have tried a number of different approaches based on the documentation but all have failed. I don't want to publish to GitHub - I just want to keep everything inside Azure. I have tried using Universal Packages with Feeds, but the Release Pipeline can only pull a specific version from the feed rather than LATEST.
Does anyone have any recommended approaches I should take?
There is Latest option in the feed of your Release Pipeline:

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.

Azure devops pipeline get work items between builds

I'm looking for a pre-made option to take 2 builds, and compare the work items or PRs completed between them. i know there are REST API options in order to find out this information ( https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/get%20work%20items%20between%20builds?view=azure-devops-rest-5.0 ) , but i would rather not build my own app for this if one already exists. Is there something built into azure devops that shows this information, preferably in an exportable format? Is there possibly an existing devops extension in the store? Any searching i do just brings up the REST API call and nothing else unfortunately.
They seem to have changed it in Azure DevOps. We are using Azure DevOps Server (on-prem). In it, the old TFS-like work items comparison between the builds is possible when you actually deploy (execute a release) in a stage:
(in the screenshot below the right popup pane is showing the work item "diff" between the build currently deployed in TEST and the one which is about to be deployed now)
If you are open to it being generated at build time, you could look at using the Generate Release Notes Build Task from the marketplace.