21

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://OrganizationName@dev.azure.com': terminal prompts disabled

The code repository is "Azure Repos Git".

git checkout -b master
git config --global user.email "xxxxxxx@xxxx.xxx"
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://PAT@dev.azure.com/OrganizationName, but it's still not working.

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

mekb
  • 507
  • 9
  • 21
VKD
  • 421
  • 1
  • 6
  • 15

3 Answers3

20

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:SYSTEM_ACCESSTOKEN@dev.azure.com/......

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

enter image description here

Shayki Abramczyk
  • 30,710
  • 15
  • 70
  • 94
  • 11
    For .yaml build pipelines (currently the default for Azure Pipelines), set the `persistCredentials: true`. See the [Checkout](https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema#checkout) options. – Jan Dolejsi Apr 15 '20 at 08:26
  • there is no`contribute` permission in Azure today, what could be an alternate permission ? – JAHelia Apr 06 '22 at 07:33
  • I can see the `Contribute` permissions today.. – Shayki Abramczyk Apr 06 '22 at 07:34
1

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
felickz
  • 4,132
  • 2
  • 32
  • 36
-3

Delete C:\program files\Git\dev\fd and then reinstall Microsoft git.

WeiHua Liu
  • 55
  • 1
  • 3