Solution

ARTIFACTORY: Using NPM client 9 with Jenkins Artifactory Plugins

AuthorFullName__c
Shisiya Sebastian
articleNumber
000005778
ft:sourceType
Salesforce
FirstPublishedDate
2023-06-11T10:53:15Z
lastModifiedDate
2023-06-11
VersionNumber
2
If you are using NPM version 9 or the latest, you will face the above issue which is due to changes in the NPM authentication configuration implemented since v8.19. This functionality is implemented in JFrog CLI v2 which is used by the new Jenkins JFrog plugin. You can use this plugin to resolve the issue. To find the difference between both plugins, please scroll down below.

You can refer to the sample Pipeline script below to test the solution:
pipeline {
    agent any
    tools {
        jfrog 'jfrog-cli'
    }
    stages {
        stage('Clone') {
            steps {
                git branch: 'master', url: "https://github.com/jfrog/project-examples.git"
            }
        }

        stage('Exec npm commands') {
            steps {
                dir('npm-example') {
                    // Configure npm project's repositories
                    jf 'npm-config --repo-resolve testpipe-npm --repo-deploy testpipe-npm'

                    // Install dependencies
                    jf 'npm install'

                    // Pack and deploy the npm package
                    jf 'npm publish'
                }
            }
        }

        stage('Publish build info') {
            steps {
                jf 'rt build-publish'
            }
        }
    }
}

Output Snippet from pipeline:
[npm-example] $ /var/lib/jenkins/tools/io.jenkins.plugins.jfrog.JfrogInstallation/jfrog-cli/jf npm-config --repo-resolve testpipe-npm --repo-deploy testpipe-npm
06:43:11 [Info] npm build config successfully created.
[Pipeline] jf
[npm-example] $ /var/lib/jenkins/tools/io.jenkins.plugins.jfrog.JfrogInstallation/jfrog-cli/jf npm install
06:43:13 [Info] Running 'npm install ' command.
up to date, audited 20 packages in 2s

found 0 vulnerabilities
06:43:17 [Info] npm install finished successfully.
[Pipeline] jf
[npm-example] $ /var/lib/jenkins/tools/io.jenkins.plugins.jfrog.JfrogInstallation/jfrog-cli/jf npm publish
06:43:17 [Info] Running npm Publish
npm notice 
npm notice 📦  npm-example@0.0.3
npm notice === Tarball Contents === 
npm notice 125B  .jfrog/projects/npm.yaml
npm notice 2.9kB README.md               
npm notice 181B  helloworld.js           
npm notice 1.5kB npm-example-0.0.3.tgz   
npm notice 198B  package.json            
npm notice === Tarball Details === 
npm notice name:          npm-example                             
npm notice version:       0.0.3                                   
npm notice filename:      npm-example-0.0.3.tgz                   
npm notice package size:  3.5 kB                                  
npm notice unpacked size: 5.0 kB                                  
npm notice shasum:        135e3d0cc8271dfb53ef960571ce270c413ce2e0
npm notice integrity:     sha512-Hgphdv0L8pEWx[...]pN1HhY/9CPkaA==
npm notice total files:   5                                       
npm notice 
06:43:18 [Info] [Thread 2] Uploading: /var/lib/jenkins/workspace/npmnew/npm-example/npm-example-0.0.3.tgz
06:43:19 [Info] npm publish finished successfully.
{
  "status": "success",
  "totals": {
    "success": 0,
    "failure": 0
  }
}