我正在为我的项目测试一些Jenkins管道命令,并且使用when
命令发生问题。Jenkins支持的语法命令
我正在使用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]
是我詹金斯不够最近的版本来支持这样的命令?我还没有发现与受版本限制的支持命令相关的任何内容。
请添加更多详细信息,说明“上述代码应该如何工作”。 –
'如'如克里斯托弗在他的评论中提到的那样'使用'。他所指的是声明管道。你正在使用的那个看起来像脚本管道。此外,我不确定'when'命令是否可用于返回布尔输出的函数。 'IsUnix()'总是产生布尔输出(默认为true)。 – Karthick
说明很好,但请编辑您的答案,并直接将答案添加到答案中,而不是评论;) – Pom12