Can't authenticate to Nexus registry from GitHub Actions/Workflow

Hello!

I’m attempting to do an install of an npm package that is stored on a Nexus server I have setup. I’m doing the following:

name: My Test
on: [push]
jobs:
  myjob:
    name: My Job
    runs-on: [ubuntu-18.04]
    steps:
      - name: Initialize npm
        run: |
          npm config set _auth $(echo -n $MYUSERNAMECOLONPASSWORD | openssl base64)
          npm config set email my@email.com
          npm config set registry https://my.nexus.domain/repository/some-group/
          npm config set always-auth true
          npm config set strict-ssl true
          npm install --production --no-save mypackage

However, I get the dreaded “Unable to authenticate, need: BASIC realm”.

npm ERR! code E401
npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"

I’m quite certain that my Nexus instance is not the problem as I can do the equivalent on Jenkins, Bitbucket Pipelines, and other environments.

I’d prefer NOT to use a GitHub Action tailored specifically for Nexus as I would like my workflow to be agnostic in regards to the type of npm registry provider it uses. (Maybe I’ll move to Artifactory in the future.)

Any help would  be greatly appreciated.

Thanks,

Ryan

I don’t have a nexus-specific insight to share here, but I did notice that something seems to be missing from your workflow compared to where I do something similar for Mac installer code signing. I would expect to see lines where you are setting up your $MYUSERNAMECOLONPASSWORD secret from the repository secrets, something like so at the step level:

env:
        MYUSERNAMECOLONPASSWORD: ${{ secrets.MYUSERNAMECOLONPASSWORD }}

@brunchboy I knew it was a good idea to post in this forum. It worked! Thanks for spotting my silly mistake!

1 Like