npm install is unable to fetch dependencies because ssh-agent is terminated after git fetch/clone

Answered

I'm using ssh keys to access git repos, defined in VCS for the given project.

Cloning is done from a private github repos (github.com/org/repoA), which is a Node project. This works fine, the issue is with the Node.JS NPM build runner, where I issue the commands:

prune
install

Prune command works fine, install fails since it is trying to fetch a dependency that is on a private github repo as well accessible with the same ssh credentials that are used in the VCS for the build.

Sample from package.json in repoA:

{...}
"dependencies": {
"private-repoB": "git+ssh://git@github.com:org/repoB.git",
{...}

RepoA has this fetch URL in VCS:
ssh://git@github.com/org/repoA

The reason why npm install fails is is because TeamCity will terminate the ssh-agent AFTER during the initial git clone/fetch during a checkout of the source code defined in the VCS. This is described in the documentation here:
https://confluence.jetbrains.com/display/TCD10/SSH+Keys+Management

During the build with agent-side checkout, the Git plugin downloads the key from the server to the agent. It temporarily saves the key on the agent's file system and removes it after git fetch/clone is completed.

How can I configure TeamCity to be able to use the ssh authentication keys during git clone, when doing an npm install ?

2
2 comments

Hi Tore,

Could please check the SSH agent build feature https://confluence.jetbrains.com/display/TCD10/SSH+Agent?

1
Avatar
Permanently deleted user

This will work. Thanks. You can close this issue.

0

Please sign in to leave a comment.