4

I'm working on a Front End Application that relies on a dependency developed by our organization but is hosted in a separate repository. It's a bitbucket repo hosted by us and is private.

We're using NPM to manage this dependency, and install it via git+https://<the-dependency-repo>.com

This works in our local environment because our credentials are cached. Please note: WE CANNOT SWITCH TO SSH. I'm aware of the ssh solution, I have no control over account management, bitbucket access etc...

When the Jenkins CI runs, it pulls our application from it's repository using credentials stored in the Credentials Plugin, and runs npm install.

The Problem:

The install fails because of authentication failure during the npm install.

What I've tried so far:

Since the git credentials are stored in the Jenkins Credential Plugin, I have access to a git username/password combination.

The precise failure happens when npm attempts to run git ls-remote ...

To circumvent this authentication failure, I am able to run a shell command before the npm install:

git config credential.helper 'cache'
git fetch https://${USERPASSCOMBO}@<repo>

The good news is that this works! NPM is able to run git fetch ls-remote without error

The bad news is that the next command git clone -q <repo> fails.

I've attempted the same solution: adding the following prior to npm install:

 git config credential.helper 'cache'
 git ls-remote https://${USERPASSCOMBO}@<repo>
 git clone https://${USERPASSCOMBO}@<repo>

note: these commands work as expected, prior to npm install

NPM install still fails however, producing the following error output:

[ERROR] npm ERR! Command failed: /bin/git clone -q https://<repo> /var/lib/jenkins/.npm/_cacache/tmp/git-clone-ed5ac1a9
[ERROR] npm ERR! warning: templates not found /tmp/pacote-git-template-tmp/git-clone-49feabe4
[ERROR] npm ERR! fatal: Authentication failed for '<repo>'
[ERROR] npm ERR! 

Any help is greatly appreciated, even a pointer towards the right direction. I've exhausted trying everything I can think of.

  • 2
    Was you able to find a solution for this issue? – Igor Milla Jul 27 '18 at 9:19
  • 1
    I have similar circumstances. I hope this question gets answered. – libzz Jan 29 '19 at 4:31
-1

Try installing from the repository with the URL git+https://user:password@<repo-url>. Note that this leaves your password out in the open, so I suggest generating an app token or similar if your repository provider supports this.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.