Karim Alaa
Karim Alaa

Reputation: 344

Merging GIT branches automatically in azure pipeline

I've GIT repo in Azure DevOps used in my pipelines.

This repo contains three branchs --> master (useless), PreProd and Prod

In pipeline I working on PreProd branch and after deployment I want to perform a task which merging the latest code in PreProd branch into a new commit in Prod.

So, is that possible and how?

Thanks in advance.

Upvotes: 3

Views: 12614

Answers (4)

TimeTerror
TimeTerror

Reputation: 624

Microsoft has added functionality to run Git commands within pipelines.

Run Git commands in a script - Azure Pipelines | Microsoft Learn

Their documentation also explains how to Merge a feature branch to main, which can easily be converted to work with two different branches such as PreProd and Prod.

Upvotes: 1

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31075

You could try API as @Tomasz suggested, or invoke git command to merge branches.

In addition, you could try Create Pull Request task to create a Pull Request and set Auto Complete:

https://marketplace.visualstudio.com/items?itemName=ShaykiAbramczyk.CreatePullRequest

Upvotes: 2

Tomasz Kaniewski
Tomasz Kaniewski

Reputation: 1195

If for some reason GitMerge task is not working for you, try calling Azure DevOps API for Git operations directly from script.

Doc: https://learn.microsoft.com/en-us/rest/api/azure/devops/git/merges/create?view=azure-devops-rest-6.0

Upvotes: 1

Hainan Zhao
Hainan Zhao

Reputation: 2092

enter image description here

I think you are looking for this.

Upvotes: 1

Related Questions