14
votes

I'm trying to merge the develop branch to the master branch when building with Azure Pipelines PowerShell task.

But while executing the command git push, I'm getting this error:

Fatal: Could not read password for 'https://[email protected]': terminal prompts disabled

The code repository is "Azure Repos Git".

git checkout -b master
git config --global user.email "[email protected]"
git config --global user.name "xxxxx"
git merge origin/develop 
git push origin master

After referring some URLs, I've created the Personal Access Token, and modified the push command as git push https://[email protected]/OrganizationName, but it's still not working.

Please let me know, if you find a solution for this issue.

2
PAT is your solution, what is "it also not worked"? what you got? - Shayki Abramczyk
Got the error as "fatal: unable to update url base from redirection:" - VKD
You need to append the team project and the git repo in the url - Shayki Abramczyk

2 Answers

14
votes

As you mentioned you need to use PAT but in this way:

git push https://{PAT}@dev.azure.com/{organization}/{project}/_git/{repo-name}

Another solution is to "Allow scripts to access the OAuth token" in the job options:

photo

In the git push use the System.AccessToken:

git push https://$env:[email protected]/......

And give push permissions to the build user (in the repo settings):

enter image description here

1
votes

Similar to Shayki's answer, but if you are not running a powershell task use:

git push https://$(System.AccessToken)@dev.azure.com/......

I am notably using

  • classic pipelines
  • an onprem Windows build agent
    • Agent job settings has Allow scripts to access the OAuth token enabled
  • command line task