Can't clone a Azure DevOps repo from a pipeline job

Viewed 3707

I'm trying to clone a git repo that is on Azure DevOps from a pipeline job, however, I get the following error (shown in the pipeline terminal on Azure DevOps):

fatal: could not read Password for 'https://test-nisohack@dev.azure.com': terminal prompts disabled

Looks like it needs a password, but I don't know how to supply or even what password to give it.

2 Answers

You need to give the password but of course you can't because is during the build.

You can solve it in 2 ways:

1) Put the password in the command:

git clone https://username:password@dev.azure.com/organization/project/_git/repo

2) Create a Personal Access Token and put it in the command:

git clone https://PAT@dev.azure.com/organization/project/_git/repo

For private projects the azure devops build VM doesn't have permission to clone your submodules. In order to give it permission to clone you can either add your username and password or add a personal access token(PAT) to the url in the gitmodules file in your repo on Azure devops. You need to change the url to https://username:password@dev.azure.com/organization/project/_git/repo or https://PAT@dev.azure.com/organization/project/_git/repo

I recommend using a PAT. You can create a PAT in Azure DevOps just look up how to do it.

Related