I am using Jenkins to manage continuous integration. One of my jobs contains the following tasks :
In the package.json file, there are some common nodeJS modules like colors, fs.extra, etc. Those are correctly installed if they are the only ones.
But there is also a module hosted on BitBucket as private :
"dependencies": {
"module": "git+ssh://[email protected]/<team>/module.git"
}
That module fails to be installed during the 'npm install' command (see Jenkins log below).
The job is run on a Windows 7 slave. If I try to make 'npm install' on a session "mySession" on the slave, it asks me for the passphrase corresponding to the private key located at C:\Users\mySession\.ssh\id_rsa (which has BitBucket access too, but which is specific to the session "mySession", and so different from the "bitbucket access" credential). Then 'npm install' ends normally by installing the module.
I tried to use the SSH Agent plugin, with the credential "bitbucket access" : it starts correctly, but it seems not to be used afterward, as the permission is denied.
Do you have any ideas how to resolve this problem and make the 'npm install' work correctly ?
Thank you for your aswers !
Jenkins log :
Construction à distance sur MySlave in workspace C:\Jenkins\workspace
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent] Java/tomcat-native ssh-agent
[ssh-agent] Registered BouncyCastle on the remote agent
[ssh-agent] Started.
[ssh-agent] Using credentials bitbucket access
...
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm WARN addRemoteGit Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit at ChildProcess.exithandler (child_process.js:203:12)
npm WARN addRemoteGit at emitTwo (events.js:87:13)
npm WARN addRemoteGit at ChildProcess.emit (events.js:172:7)
npm WARN addRemoteGit at maybeClose (internal/child_process.js:818:16)
npm WARN addRemoteGit at Socket.<anonymous> (internal/child_process.js:319:11)
npm WARN addRemoteGit at emitOne (events.js:77:13)
npm WARN addRemoteGit at Socket.emit (events.js:169:7)
npm WARN addRemoteGit at Pipe._onclose (net.js:469:12)
npm WARN addRemoteGit git+ssh://[email protected]/<team>/module.git resetting remote C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\ssh-git-bitbucket-org-<team>-module-git-2a4d53e0
because of error: { [Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit ]
npm WARN addRemoteGit killed: false,
npm WARN addRemoteGit code: 1,
npm WARN addRemoteGit signal: null,
npm WARN addRemoteGit cmd: 'git -c core.longpaths=true config --get remote.origin.url' }
npm ERR! git clone --template=C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://[email protected]/<team>/module.git
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\ssh-git-bitbucket-org-<team>-module-git-2a4d53e0: Cloning into bare repository
'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\ssh-git-bitbucket-org-<team>-module-git-2a4d53e0'...
npm ERR! git clone --template=C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://[email protected]/<team>/module.git
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\ssh-git-bitbucket-org-<team>-module-git-2a4d53e0: Permission denied (publickey).
npm ERR! git clone --template=C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://[email protected]/<team>/module.git
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\ssh-git-bitbucket-org-<team>-module-git-2a4d53e0: fatal: Could not read from remote repository.
npm ERR! git clone --template=C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://[email protected]/<team>/module.git
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\ssh-git-bitbucket-org-<team>-module-git-2a4d53e0:
npm ERR! git clone --template=C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://[email protected]/<team>/module.git
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\ssh-git-bitbucket-org-<team>-module-git-2a4d53e0: Please make sure you have the correct access rights
npm ERR! git clone --template=C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://[email protected]/<team>/module.git
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\ssh-git-bitbucket-org-<team>-module-git-2a4d53e0: and the repository exists.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v4.2.3
npm ERR! npm v2.14.7
npm ERR! code 128
npm ERR! Command failed: git -c core.longpaths=true clone --template=C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://[email protected]/<team>/module.git
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\ssh-git-bitbucket-org-<team>-module-git-2a4d53e0
npm ERR! Cloning into bare repository 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache\_git-remotes\ssh-git-bitbucket-org-<team>-module-git-2a4d53e0'...
npm ERR! Permission denied (publickey).
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!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
...
[ssh-agent] Stopped.
May be usefull :
I had a similar problem in a Jenkinsfile
where npm
would not access a private git repo even though I could do it as the same user from the commandline. It seemed as if the .ssh/config
was being ignored. I was able to work around this with the following snippet in my Jenkinsfile
:
sh "eval \$(ssh-agent); ssh-add /home/tomcat/.ssh/mysshkey; npm install"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With