We have a project that's still using yarn v1.22.19 but we need to migrate it to use a new instance of JFrog Artifactory that requires authentication.
However, we cannot work out where to set this configuration. We've set it in npm but yarn seems to ignore it as the jfrog logs are saying the request is coming as an anonymous user. npm whoami
returns the user we expect though.
jf
doesn't support yarn v1.
We have tried yarn config set _authToken ${{ secret.superToken }}
as well as yarn config set //my.jfrog.ui/artifactory/api/super-npm-repo:_authToken ${{ secret.superToken }}
but this has also not worked.
yarn's modern documentation implies the above should be possible (here).
The build is building inside a node:lts-alpine
docker container
It is possible to authenticate and publish or pull packages with Yarn to/from Artifactory by configuring the .npmrc
file as below:
//<Artifactory-URL>/artifactory/api/npm/<npm-repo-name>/:_password=xxxxxxxxxxxx
//<Artifactory-URL>/artifactory/api/npm/<npm-repo-name>/:username=<UserName>
//<Artifactory-URL>/artifactory/api/npm/<npm-repo-name>/:email=youremail@email.com
//<Artifactory-URL>/artifactory/api/npm/<npm-repo-name>/:always-auth=true
registry=http://<Artifactory-URL>/artifactory/api/npm/<npm-repo-name>/
The snippet for the .npmrc
configuration file can be generated and copied following the Set Me Up widget in Artifactory UI (after clicking on the relevant repository), to be able to both publish and pull packages it will be required to use the snippet generated for scope packages.
In addition to the above it will be required to configure the .yarnrc
file with the email address and the user name for Artifactory, this can be done by the $yarn login command, for example:
email my-email@address.com
username <UserName>
For reference, link to JFrog documentation regrading Using Yarn