To add to the above answers - there's no need to create a PAT if your pipeline build agent has sufficient permissions.
- checkout: self
persistCredentials: true
- bash: |
git config --global user.email "[email protected]"
git config --global user.name "Azure DevOps Pipeline"
name: GitConfig
- pwsh: |
git checkout -b MyBranch main
New-Item test.txt //add something new
git add test.txt
git commit -m "Test commit"
git push origin "HEAD:MyBranch"
az repos pr create <INSERT ARGS HERE>
env:
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
The code required comes from the following sources