Jenkins 支持的语法命令
Jenkins Supported Syntax Commands
我正在为我的项目测试一些 Jenkins Pipeline 命令,但我在使用 when
命令时遇到问题。
我正在使用 Jenkins 2.19,但在使用此命令时遇到了不支持的 DSL 命令错误。
node{
stage('Hello'){
when{
isUnix()
}
echo 'Hello'
}
}
错误:
java.lang.NoSuchMethodError: No such DSL method 'when' found among steps [archive, bat, build, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo, emailext, emailextrecipients, envVarsForTool, error, fileExists, getContext, git, input, isUnix, library, libraryResource, load, mail, milestone, node, parallel, properties, publishHTML, pwd, readFile, readTrusted, resolveScm, retry, script, sh, sleep, stage, stash, step, svn, timeout, timestamps, tool, unarchive, unstash, waitUntil, withContext, withCredentials, withDockerContainer, withDockerRegistry, withDockerServer, withEnv, wrap, writeFile, ws] or symbols [all, always, ant, antFromApache, antOutcome, antTarget, any, apiToken, architecture, archiveArtifacts, artifactManager, batchFile, booleanParam, branch, buildButton, buildDiscarder, caseInsensitive, caseSensitive, choice, choiceParam, clock, cloud, command, configFile, configFileProvider, cron, crumb, defaultView, demand, disableConcurrentBuilds, docker, dockerfile, downloadSettings, downstream, dumb, envVars, environment, expression, file, fileParam, filePath, fingerprint, frameOptions, freeStyle, freeStyleJob, git, github, githubPush, gradle, hyperlink, hyperlinkToModels, installSource, jdk, jdkInstaller, jgit, jgitapache, jnlp, jobDsl, jobName, junit, label, lastDuration, lastFailure, lastGrantedAuthorities, lastStable, lastSuccess, legacy, legacySCM, list, local, location, logRotator, loggedInUsersCanDoAnything, masterBuild, maven, maven3Mojos, mavenErrors, mavenMojos, mavenWarnings, modernSCM, msbuild, msbuildError, msbuildWarning, myView, nodeProperties, nonStoredPasswordParam, none, overrideIndexTriggers, paneStatus, parameters, password, pattern, pipeline-model, pipelineTriggers, plainText, plugin, projectNamingStrategy, proxy, queueItemAuthenticator, quietPeriod, run, runParam, schedule, scm, scmRetryCount, search, security, shell, skipDefaultCheckout, skipStagesAfterUnstable, slave, stackTrace, standard, status, string, stringParam, swapSpace, text, textParam, tmpSpace, toolLocation, unsecured, upstream, usernameColonPassword, usernamePassword, viewsTabBar, weather, zfs, zip] or globals [currentBuild, docker, env, params, pipeline, scm]
我的 Jenkins 版本是否不够新,无法支持这样的命令?我还没有发现任何与支持的命令受版本限制相关的内容。
when
命令是 Declarative Pipeline syntax 的一部分;它不会在脚本化管道中工作。
脚本管道中的粗略等效项是:
node {
stage('Hello') {
if (isUnix()) {
echo 'Hello'
}
}
}
node{
stage('Hello'){
isUnix()
echo 'Hello'
}
}
上面的代码应该可以工作。
话虽如此,声明式管道和脚本式管道之间存在很多差异。一个关键的区别是语法用法。 'when' 和 'isUnix()' 命令 may/do 不能齐头并进。例如,请参考 this link 了解如何使用 'when' 命令。此外,我不确定 'when' 命令是否可用于返回布尔输出的函数。 'IsUnix()' 始终产生布尔输出(默认输出为真)。
我正在为我的项目测试一些 Jenkins Pipeline 命令,但我在使用 when
命令时遇到问题。
我正在使用 Jenkins 2.19,但在使用此命令时遇到了不支持的 DSL 命令错误。
node{
stage('Hello'){
when{
isUnix()
}
echo 'Hello'
}
}
错误:
java.lang.NoSuchMethodError: No such DSL method 'when' found among steps [archive, bat, build, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo, emailext, emailextrecipients, envVarsForTool, error, fileExists, getContext, git, input, isUnix, library, libraryResource, load, mail, milestone, node, parallel, properties, publishHTML, pwd, readFile, readTrusted, resolveScm, retry, script, sh, sleep, stage, stash, step, svn, timeout, timestamps, tool, unarchive, unstash, waitUntil, withContext, withCredentials, withDockerContainer, withDockerRegistry, withDockerServer, withEnv, wrap, writeFile, ws] or symbols [all, always, ant, antFromApache, antOutcome, antTarget, any, apiToken, architecture, archiveArtifacts, artifactManager, batchFile, booleanParam, branch, buildButton, buildDiscarder, caseInsensitive, caseSensitive, choice, choiceParam, clock, cloud, command, configFile, configFileProvider, cron, crumb, defaultView, demand, disableConcurrentBuilds, docker, dockerfile, downloadSettings, downstream, dumb, envVars, environment, expression, file, fileParam, filePath, fingerprint, frameOptions, freeStyle, freeStyleJob, git, github, githubPush, gradle, hyperlink, hyperlinkToModels, installSource, jdk, jdkInstaller, jgit, jgitapache, jnlp, jobDsl, jobName, junit, label, lastDuration, lastFailure, lastGrantedAuthorities, lastStable, lastSuccess, legacy, legacySCM, list, local, location, logRotator, loggedInUsersCanDoAnything, masterBuild, maven, maven3Mojos, mavenErrors, mavenMojos, mavenWarnings, modernSCM, msbuild, msbuildError, msbuildWarning, myView, nodeProperties, nonStoredPasswordParam, none, overrideIndexTriggers, paneStatus, parameters, password, pattern, pipeline-model, pipelineTriggers, plainText, plugin, projectNamingStrategy, proxy, queueItemAuthenticator, quietPeriod, run, runParam, schedule, scm, scmRetryCount, search, security, shell, skipDefaultCheckout, skipStagesAfterUnstable, slave, stackTrace, standard, status, string, stringParam, swapSpace, text, textParam, tmpSpace, toolLocation, unsecured, upstream, usernameColonPassword, usernamePassword, viewsTabBar, weather, zfs, zip] or globals [currentBuild, docker, env, params, pipeline, scm]
我的 Jenkins 版本是否不够新,无法支持这样的命令?我还没有发现任何与支持的命令受版本限制相关的内容。
when
命令是 Declarative Pipeline syntax 的一部分;它不会在脚本化管道中工作。
脚本管道中的粗略等效项是:
node {
stage('Hello') {
if (isUnix()) {
echo 'Hello'
}
}
}
node{
stage('Hello'){
isUnix()
echo 'Hello'
}
}
上面的代码应该可以工作。
话虽如此,声明式管道和脚本式管道之间存在很多差异。一个关键的区别是语法用法。 'when' 和 'isUnix()' 命令 may/do 不能齐头并进。例如,请参考 this link 了解如何使用 'when' 命令。此外,我不确定 'when' 命令是否可用于返回布尔输出的函数。 'IsUnix()' 始终产生布尔输出(默认输出为真)。