How I can access private bitbucket repository via bitbucket-pipeline?

Andrey Selemenev October 26, 2022

If I'm using nodejs version > 12.14, then I'm receiving access error:

+ npm install eslint@8.25.0
npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://git@bitbucket.org/someprivatereponame/someprivatereponame.git
npm ERR! Warning: Permanently added the RSA host key for IP address 'X.X.X.X' to the list of known hosts.
npm ERR! git@bitbucket.org: 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! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-10-26T10_45_48_521Z-debug-0.log

In packages json file package specified like:

"common-module": "bitbucket:someprivatereponame/common-module#v1.0"

where v1.0 is tag in git.

 

My pipeline file:

image: node:18.11

definitions:
  steps:
    - step: &lint
        name: Lint application
        caches:
          - node
        script:
          - npm install eslint@8.25.0
          - npm run lint

clone:
  depth: 1

pipelines:
  branches:
    master: # or the name of your main branch
      - step: *lint

So the question, what needs to be done to resolve this issue with private repo access? How and where I can provide ssh key?

2 answers

1 accepted

0 votes
Answer accepted
Andrey Selemenev November 11, 2022

I found the issue, it was related to passphrase protected ssh key. So for bitbucket-pipelines we should use non-passphrased keys.

0 votes
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 26, 2022

Hi @Andrey Selemenev,

Welcome to the community.

You can either generate or use your own SSH keys from your repository Pipelines SSH keys settings.

  • Go to your repository
  • Click Repository settings
  • Click SSH keys (Under Pipelines)

Once you have set up the SSH key there, you can copy the public SSH key and either add it to your account's settings or the private repository Access keys.

After that, you can run your Pipelines build again.

Let me know how it goes.

Regards,
Mark C

Andrey Selemenev October 31, 2022

Let me try, but what's the difference, why for node v12 it's working fine, but for more new versions it's failing?

Andrey Selemenev October 31, 2022

BTW, I have followed all your instructions, copy my public key from repo where I have pipeline running, added this key for private package which I need to access, but no luck. I still receiving the same error.

Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 31, 2022

Hi @Andrey Selemenev

For your package.json file, could you try the below SSH URL connection?

"common-module": "ssh://bitbucket.org/workspace_id/repo_name.git"


If you're still getting the same error after that, I'm suspecting there's something causing it with the Node version > 12.

Regards,
Mark C

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events