Stephanie
Stephanie

Reputation: 151

How do I get Azure DevOps releases for a particular repository via the DevOps APIs?

I'm working on automating approvals of DevOps releases through another system. The problem is, I need to be able to identify which releases are on pipeline(s) built from a particular repository; I'm fine with having to make multiple API calls to get the right identifiers but I don't see any APIs where I can get information on the repository a pipeline is built on.

(Unfortunately my organization places multiple repositories per project so I can't do it with just the project specifier).

Is there some DevOps API I missed that I can get down to the level of info on which repository the pipeline uses?

Upvotes: 0

Views: 780

Answers (1)

Vito Liu
Vito Liu

Reputation: 8278

Create release pipeline and then we need to select the Artifacts, we could select Build or Azure Repo Git

enter image description here

If you are select Azure Repo Git

We could get the release repo info via this REST API Releases - Get Release and then search artifacts in the response body, then we could get the release repo info

GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}?api-version=6.1-preview.8

Result:

enter image description here

If you are using Build as the artifact, we could get the build info, such as build ID, build definition ID and build definition name, check the pic below:

enter image description here

Then run this REST API Builds - Get to get the build detail info

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=6.1-preview.6

enter image description here

And search repository in the response body to get the repo info

enter image description here

Upvotes: 1

Related Questions