npm install needs authentication in VSTS hosted build

832 views Asked by At

In Visual Studio Team Services, I am trying to run npm install on a hosted build server prior to my solution getting built. But access to our https://our_url.visualstudio.com/GIT is being denied:

npm ERR! git clone --template=C:\NPM\Cache_git-remotes_templates --mirror https://our_url.visualstudio.com/GIT/_git/our_url-gulp-bundle-helper C:\NPM\Cache_git-remotes\git-https-our_url-visualstudio-com-GIT-git-our_url-gulp-bundle-helper-2-2-7-88eb446d: Cloning into bare repository 'C:\NPM\Cache_git-remotes\git-https-our_url-visualstudio-com-GIT-git-our_url-gulp-bundle-helper-2-2-7-88eb446d'...

npm ERR! git clone --template=C:\NPM\Cache_git-remotes_templates --mirror https://our_url.visualstudio.com/GIT/_git/our_url-gulp-bundle-helper C:\NPM\Cache_git-remotes\git-https-our_url-visualstudio-com-GIT-git-our_url-gulp-bundle-helper-2-2-7-88eb446d: Fatal: InvalidOperationException encountered.

npm ERR! git clone --template=C:\NPM\Cache_git-remotes_templates --mirror https://our_url.visualstudio.com/GIT/_git/our_url-gulp-bundle-helper C:\NPM\Cache_git-remotes\git-https-our_url-visualstudio-com-GIT-git-our_url-gulp-bundle-helper-2-2-7-88eb446d: fatal: Authentication failed for 'https://our_url.visualstudio.com/GIT/_git/our_url-gulp-bundle-helper/'

npm ERR! git clone --template=C:\NPM\Cache_git-remotes_templates --mirror https://our_url.visualstudio.com/GIT/_git/our_url-gulp-bundle-helper C:\NPM\Cache_git-remotes\git-https-our_url-visualstudio-com-GIT-git-our_url-gulp-bundle-helper-2-2-7-88eb446d: fatal: Authentication failed for 'https://our_url.visualstudio.com/GIT/_git/our_url-gulp-bundle-helper/'

It appears it's simply our access being denied, which I thought I was fixing by going into GIT and adding the 'Project Collection Build Service Accounts' to the team permissions, but that doesn't seem to do the trick. Any idea what i need to do to get the hosted build server to have permissions to our GIT server?

1

There are 1 answers

0
naspinski On

Needed to set up my personal access token and pass it through with my package.json:

"my_package": git+https://my-name%40my-domain.com:[TOKEN]@my_url.visualstudio.com/GIT/_git/my_package#2.2.7