Home > Net >  Jenkins pipeline: No such DSL method 'withNPM' found
Jenkins pipeline: No such DSL method 'withNPM' found

Time:10-02

I Am getting "No such DSL method 'withNPM' found " error with mentioned code below.

I already have my npm-global-config and npmrc config file in Jenkins config file management.

Do i need to configure or install something more?

stage('Test'){
        agent {
            docker {
                reuseNode true
                image 'cypress/browsers'
                registryUrl 'https://remote-docker.artifactory.com'
                args '-v $WORKSPACE:/build'
            }
        }
        steps {
            withNPM(npmrcConfig: 'npm-global-config') {
                sh 'npm ci'
                sh 'npm run start-test'
            }
        }
    }

Error

java.lang.NoSuchMethodError: No such DSL method 'withNPM' found among steps [ArtifactoryGradleBuild, MavenDescriptorStep, addInteractivePromotion, archive, artifactoryBuildTrigger, artifactoryDistributeBuild, artifactoryDownload, artifactoryEditProps, artifactoryGoPublish, artifactoryGoRun, artifactoryMavenBuild, artifactoryNpmCi, artifactoryNpmInstall, artifactoryNpmPublish, artifactoryNugetRun, artifactoryPipRun, artifactoryPromoteBuild, artifactoryUpload, bat, build, buildAppend, catchError, checkout, collectEnv, collectIssues, compareVersions, conanAddRemote, conanAddUser, container, containerLog, createDockerBuildStep, createReleaseBundle, deleteDir, deleteReleaseBundle, deployArtifacts, dir, distributeReleaseBundle, dockerFingerprintFrom, dockerFingerprintRun, dockerNode, dockerPullStep, dockerPushStep, dsCreateReleaseBundle, dsDeleteReleaseBundle, dsDistributeReleaseBundle, dsSignReleaseBundle, dsUpdateReleaseBundle, echo, emailext, emailextrecipients, envVarsForTool, error, fileExists, findBuildScans, findFiles, getArtifactoryServer, getContext, getJFrogPlatformInstance, getNextSemanticVersion, git, gitChangelog, initConanClient, input, isUnix, jfPipelines, jfrogInstance, junit, library, libraryResource, load, lock, mail, milestone, newArtifactoryServer, newBuildInfo, newGoBuild, newGradleBuild, newJFrogPlatformInstance, newMavenBuild, newNpmBuild, newNugetBuild, newPipBuild, node, nodesByLabel, office365ConnectorSend, parallel, podTemplate, powershell, prependToFile, properties,  timestamperConfig, timezone, tmpSpace, toolLocation, triggeredBy, unsecured, untrusted, upstream, upstreamDevelopers, userSeed, usernameColonPassword, usernamePassword, viewsTabBar, weather, withAnt, withSonarQubeEnv, workspace, x509ClientCert, zip] or globals [Artifactory, JFrog, currentBuild, docker, env, params, pipeline, scm]
at java.lang.Thread.run(Thread.java:748)
 Finished: FAILURE

CodePudding user response:

Resolved the issue by installing Pipeline-npm plugin in jenkins. https://plugins.jenkins.io/pipeline-npm

CodePudding user response:

I recommend using NodeJS to specify your node version

plugin site: https://plugins.jenkins.io/nodejs/

here is demo

pipeline {
  agent any
  tools { 
    nodejs "your_node_js_tag_name"
  }
  stages {
    stage('What's node version') {
      steps {
        sh 'node --version'
      }
    }
  }
}
  • Related