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.
More on Integrations: SonarQube, Nexus, Artifactory, Docker, Trivy
How do you integrate SonarQube with a Jenkins pipeline?IntermediateHow does `waitForQualityGate` work?IntermediateHow do you deploy Maven artifacts to Nexus from Jenkins?IntermediateHow do you use JFrog Artifactory from Jenkins?IntermediateHow do you build and push a Docker image from Jenkins on a VM agent?BeginnerHow do you scan an image with Trivy in a pipeline and gate on results?Intermediate