Search code examples
sshazure-devopsbitbucketbitbucket-cloud

Additional connection to BitBucket using SSH in VSTS


I've been trying to set up a new build in VSTS for a project that uses BitBucket. The reason for this is that I want to move away from TeamCity. I've set up my connection to BitBucket using OAuth, which is working fine.

My problem is that when I run an npm install task, it fails with the message:

npm ERR! Error while executing:
npm ERR! C:\agents\2.139.1\externals\git\cmd\git.EXE ls-remote -h -t ssh://git@bitbucket.org/{project}/{repo}.git
npm ERR! 
npm ERR! Host key verification failed.
npm ERR! fatal: Could not read from remote repository.
npm ERR! 
npm ERR! Please make sure you have the correct access rights 
npm ERR! and the repository exists.
npm ERR! 
npm ERR! exited with error code: 128

One of the dependencies in package.json refers to another repository in BitBucket via SSH. I can't seem to find a way to add an SSH key to my build in order to authenticate with BitBucket. I also cannot change the package.json file, as it's currently being used by a development team and current TeamCity project configuration.

Is there a way to add an SSH key to the build in VSTS, and if so - where is it?


Solution

  • There is an Install SSH Key build task you can use to install an SSH key prior to a build or release.