I have an azure organization with multiple projects and repositories. Whenever I make some commits in any repository in a project, a new release gets created under a pipeline with the same name as that repo under a different project and using CI/CD the same release gets deployed on a test environment. After testing the same on test env, I want to automate the process of deploying 100+ pipelines(for various different repos which I've updated) on production env. I'm fairly new to this can you suggest a way to automate this process.
I've looked into azure CLI and have seen that there is relation in the merge id created in the repo is displayed under that new release created(Like this release was created using this merge image), someway I can fetch that id and for that repos pipeline which was created deploy the same on a specific environment. Each pipeline has multiple releases hence I want to deploy on the release created with my merge.
FYI, I am updating a common value in all repos at once using a cli script, hence all PR's are created with the same task attached. Just mentioning this as there could be some way to fetch the merge id from PR's made using that task number.
Currently I'm trying to do this with gitbash + azure cli, I'm open to powershell, or even if there's a way to do this by creating a new pipeline which can handle this thing, I'm up to learning that also.
Thanks!
It took me a lot of time trying to find the perfect REST calls, SO here's what I did:
This rest call gives the work item related info in a JSON response. where you'll find workItemUpdates link in the response.
Hence this way we can fetch all Pr's Linked with a work Item.
Under repository.name, I got repo name which used in : GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}?api-version=4.1
Under value[0].commitId, we get the latest SHA commit id, We need this id to find the release created with our edit.
Now going on to Pipelines. GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions/{definitionId}?api-version=6.0 This rest call gives the release definition info and we can fetch the latest release created info from this this is the only drawback, as we wont be able to fetch the info of all releases for that definition. In this response we can fetch the release id(lastRelease.id is the path)
Use this release id in : GET https://vsrm.dev.azure.com/hmcloud/Appeaser-System/_apis/release/releases/{release id}?api-version=6.0
To get that release related info, do a loop in environments to get the environment id for the specific stage you want this to be deployed on and finally used this to deploy: How do I deploy a release from DevOps via the API