Interview Prep/Jenkins/Integrations: SonarQube, Nexus, Artifactory, Docker, Trivy

How do you publish npm packages or pull dependencies through Nexus or Artifactory?

BeginnerConceptIntegrations: SonarQube, Nexus, Artifactory, Docker, Trivy
Answer

Point npm at a group/virtual repository that proxies npmjs and hosts internal packages, and authenticate with a token from credentials:

withCredentials([string(credentialsId: 'npm-token', variable: 'NPM_TOKEN')]) {
  sh '''
    echo "registry=https://nexus.example.com/repository/npm-group/" > .npmrc
    echo "//nexus.example.com/repository/npm-group/:_authToken=${NPM_TOKEN}" >> .npmrc
    npm ci
  '''
}

The proxy caches packages close to the agents, speeding ephemeral builds and surviving upstream outages.

All Jenkins questions Roadmap: Jenkins

More on Integrations: SonarQube, Nexus, Artifactory, Docker, Trivy