VKD
VKD

Reputation: 847

Could not read Password for 'Repository URL': terminal prompts disabled

I am executing a batch file in Azure DevOps Pipeline which has following statement.

git init    
git checkout -b %BranchName%    
git remote add origin %RepoURL%    
git fetch && git checkout %BranchName%

The parameters gets the values from Variables. But I am getting the below error.

"Could not read Password for '<Repository URL>': terminal prompts disabled"

I have tried to set the value for the RepoURL parameter as follows.

https://<CollectionName>@dev.azure.com/<CollectionName>/<ProjectName>/_git/<RepoName>
https://<PAT>@dev.azure.com/<CollectionName>/<ProjectName>/_git/<RepoName>

Many post in this forum suggest to use PAT. So tried the git pull statement as follows.

git pull %RepoURL%

But no luck. Still getting the same error. Please anyone let me know how to solve this issue.

Thanks.

Upvotes: 1

Views: 13217

Answers (3)

Ratheesh Mahalingam
Ratheesh Mahalingam

Reputation: 31

If you are using an Azure self-hosted agent, delete the .gitconfig file located at C:\Users{your-user} and re-run the pipelines.

Upvotes: 0

Leo Liu
Leo Liu

Reputation: 76910

Could not read Password for 'Repository URL': terminal prompts disabled

If your repo is from another project, you also need to pay attention that you turn off the settings Limit job authorization scope to referenced Azure DevOps repositories:

Project Settings->Settings:

enter image description here

With this option enabled, it reduce the scope of access for all pipelines to only Azure DevOps repositories explicitly referenced by a checkout step in the pipeline job that uses that repository.

Upvotes: 2

Alina Wang-MSFT
Alina Wang-MSFT

Reputation: 572

According to your description, I use the following method for testing, and it works well.

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

In order to solve this problem, please check the following things:

1.Enable ‘Allow scripts to access the OAuth token’ in the Agent job options. enter image description here

In the git remote add origin %RepoURL% use the System.AccessToken:

git remote add origin %RepoURL%    
 
RepoURL: https://$env:[email protected]/{organization}/{project}/_git/{repo name}
  1. Go to Project Settings-> Repositories under Repos, grant permissions to the build user (in the repo settings). enter image description here

Upvotes: 3

Related Questions