jenkins - Jenkins 管道:没有找到这样的 DSL 方法“withNPM”
问题描述
我收到“没有找到这样的 DSL 方法'withNPM'”错误,下面提到的代码。
我已经在 Jenkins 配置文件管理中拥有我的 npm-global-config 和 npmrc 配置文件。
我需要配置或安装更多东西吗?
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'
}
}
}
错误
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
解决方案
我建议使用 NodeJS 来指定你的节点版本
插件站点:https ://plugins.jenkins.io/nodejs/
这是演示
pipeline {
agent any
tools {
nodejs "your_node_js_tag_name"
}
stages {
stage('What's node version') {
steps {
sh 'node --version'
}
}
}
}
推荐阅读
- javascript - 当没有任何东西表明它是一个时,输入字段被视为密码字段
- sql-server - SQL Server 还原 BACPAC 在缺少用户定义的表类型时引发错误
- python-3.x - 变量中的 Unicode 字符名称
- python - 如何在 BGE 的 python 脚本中获取对象动作/动画的名称?
- reactjs - 从 mongodb 设置选择菜单的默认值
- apache - 需要 Apache 反向代理帮助
- c# - Web.config 运行时/legacyCorruptedStateExceptionsPolicy 设置不起作用
- f# - 简单 rec 函数中的 F# 和内存泄漏
- vb.net - VB.net 中索引属性的 PropertyChanged
- machine-learning - 如何在 Julia 中实现特征提取