I have a requirement to automate the merge through azure pipeline upon deployment is complete.
For example : I have a branch – ‘release/1.0.0
‘ which is used for the deployment, post deployment this branch needs to be auto merged into main branch without any pull request.
I’m using a bash task to execute the git commands as below:
- ${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/release/') }}:
- task: Bash@3
displayName: "Auto merge release"
name: "Auto_merge"
inputs:
targetType: "inline"
script: |
git config --global user.name "AzureDevOps Agent"
git config --global user.email "[email protected]"
git checkout origin/main
git fetch
git merge --ff $(Build.SourceBranchName)
git push origin
Here is the error in azure pipeline:
Can you please help me fix this ?
Note: I don’t want to create any pull request to handle the auto merge, just not to clutter the Pull requests in ADO.
I want to achieve this through git merge
without any pull request
2
Answers
Regarding git merge, there is an option
--ff
, but not-ff
.Make sure to use the right syntax.
Vonc’s answer is already to solve your first issue.
And I write a YAML with related scripts to achieve your requirements(without PR):
I works fine on my side: