0

We use Azure DevOps Pipelines and have a pipeline using Microsoft hosted agent.

There is a step we need in our build pipeline that runs 'yarn install' to fetch a repo hosted on our Bitbucket Cloud private repository.

We have tried:

  • persistCredentials: true
  • Dynamically editing the URL in the package.json file from within the Pipeline to https://:@bitbucket.org/... (where is a secure variable) but this seems to be written as '***'
  • InstallSSHKey@0 task to then use ssh instead of https to fetch, but this also fails.

We are expecting yarn install to be able to authenticate with our private Bitbucket cloud repo and pull the package/repo.

  • How does the value being used in the `package.json` file looks like? `"dependencies": { "package-name": "git+https://:@.git" }` or `git+ssh://...` should also work – Jhilton Jun 09 '23 at 01:22
  • @Jhilton it is: "package-name": "https://.git" I am also trying to do some testing with ssh://git@... We are open to using either. We currently have a task that will modify that line in the pipeline to match https/ssh depending on what we choose to use. However currently changing https://repo.com/org/reponame.git to ssh://git@repo.com/org/reponame.git causes "Invalid package.json in package.json" error. So I am also troubleshooting that at the moment. Is git+XXXXX required? – Justin Puah Jun 09 '23 at 04:16
  • Yes, the `git+` syntax is supported both in npm and yarn. Maybe you can check this other answer https://stackoverflow.com/questions/43411864/how-to-install-package-from-github-repo-in-yarn – Jhilton Jun 09 '23 at 04:50

1 Answers1

0

For future reference I ended up doing 'yarn remove ' and 'yarn add' with some regex to massage the URL into the ssh format.

The InstallSSHKey@0 task is now working - just had to add values for every single parameter (including the non-optional ones).