詹金斯的新手;简单构建失败,在步骤中找不到这样的 DSL 方法 'pipeline'
New to Jenkins; simple build fails with No such DSL method 'pipeline' found among steps
我有一个简单的 hello world 项目,它在新的 Jenkins 安装上失败了。我正在按照 URL 中的说明进行操作:https://code-maven.com/jenkins-pipeline-hello-world
作为参考,安装了以下简单的构建管道插件:
构建管道插件 1.5.8
管道保留 运行 步骤 1.0
管道实用程序步骤 2.6.1
管道:API 2.40
管道:基本步骤 2.22
管道:构建步骤 2.13
管道:Groovy 2.85
管道:输入步骤 2.12
管道:作业 2.40
管道:保持环境步骤插件 1.0
管道:节点和进程 2.36
管道:REST API 插件 2.18
管道:SCM 步骤 2.11
管道:阶段步骤 2.5
管道:舞台视图插件 2.18
管道:步骤 API 2.23
流水线:支持APIs 3.6
可锁定资源
(这也使得我在发帖前阅读的以下链接不适用:Jenkins pipeline - No such DSL method 'build', , No such DSL method 'pipeline' found among steps)
因此,根据我正在学习的教程,我创建了一个管道,并在配置中将以下代码放入“管道”部分:
pipeline {
agent { label 'master' }
stages {
stage('build') {
steps {
echo "Hello World!"
}
}
}
}
当我点击“立即构建”按钮时,我从控制台输出中得到以下信息:
Started by user dogzilla
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] End of Pipeline
java.lang.NoSuchMethodError: No such DSL method 'pipeline' found among steps [archive, bat, build, catchError, checkout, compareVersions, deleteDir, dir, echo, error, fileExists, findFiles, getContext, input, isUnix, junit, keepEnv, keepRunning, load, lock, mail, node, nodesByLabel, parallel, powershell, publishChecks, pwd, pwsh, readCSV, readFile, readJSON, readManifest, readMavenPom, readProperties, readYaml, retry, sh, sha1, sleep, stage, stash, step, tee, timeout, tm, tool, touch, unarchive, unstable, unstash, unzip, waitUntil, warnError, withContext, withEnv, wrap, writeCSV, writeFile, writeJSON, writeMavenPom, writeYaml, ws, zip] or symbols [all, always, apiToken, architecture, archiveArtifacts, artifactManager, batchFile, booleanParam, buildButton, buildDiscarder, buildDiscarders, caseInsensitive, caseSensitive, choice, choiceParam, clock, command, credentials, cron, crumb, defaultView, demand, disableConcurrentBuilds, disableResume, downstream, dumb, durabilityHint, envVars, envVarsFilter, file, fileParam, filePath, fingerprint, fingerprints, frameOptions, freeStyle, freeStyleJob, fromScm, fromSource, headRegexFilter, headWildcardFilter, hyperlink, hyperlinkToModels, installSource, javadoc, jdk, jdkInstaller, jnlp, jobBuildDiscarder, jobName, junitTestResultStorage, lastDuration, lastFailure, lastGrantedAuthorities, lastStable, lastSuccess, legacy, list, local, location, logRotator, loggedInUsersCanDoAnything, mailer, masterBuild, maven, maven3Mojos, mavenErrors, mavenMojos, mavenWarnings, myView, nodeProperties, none, paneStatus, parameters, password, pattern, permanent, pipelineTriggers, plainText, plugin, pollSCM, projectNamingStrategy, proxy, queueItemAuthenticator, quietPeriod, resourceRoot, retainOnlyVariables, run, runParam, schedule, scmRetryCount, scriptApproval, scriptApprovalLink, search, security, shell, simpleBuildDiscarder, slave, sourceRegexFilter, sourceWildcardFilter, sshPublicKey, standard, status, string, stringParam, swapSpace, text, textParam, timezone, tmpSpace, toolLocation, unsecured, upstream, userSeed, viewsTabBar, weather, zfs, zip] or globals [currentBuild, env, params]
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:216)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.kohsuke.groovy.sandbox.impl.Checker.call(Checker.java:163)
at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:157)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:142)
at org.kohsuke.groovy.sandbox.impl.Checker.call(Checker.java:161)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
at WorkflowScript.run(WorkflowScript:1)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
at com.cloudbees.groovy.cps.Next.step(Next.java:83)
at com.cloudbees.groovy.cps.Continuable.call(Continuable.java:174)
at com.cloudbees.groovy.cps.Continuable.call(Continuable.java:163)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access[=12=]1(SandboxContinuable.java:18)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access0(CpsThreadGroup.java:96)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.call(CpsThreadGroup.java:312)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.call(CpsThreadGroup.java:276)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService.call(CpsVmExecutorService.java:67)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService.run(SingleLaneExecutorService.java:136)
at jenkins.util.ContextResettingExecutorService.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService.run(ImpersonatingExecutorService.java:59)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
想知道为什么会失败。如果出现 java 问题,Jenkins 甚至不会启动。我已经安装了说明中的所有插件和我读过的一些故障排除链接。
我怎样才能让它工作?
您似乎缺少了一堆管道插件。确保安装“Pipeline”(ID:workflow-aggregator),它将安装其他管道缺少的插件。
https://plugins.jenkins.io/workflow-aggregator/#dependencies
有人在其他论坛上帮助我时,我看到了答案。在这里张贴以防它对其他人有用。
在https://www.jenkins.io/doc/book/pipeline/syntax/中说:
所有有效的声明式管道都必须包含在管道块中,例如:
pipeline {
/* insert Declarative Pipeline here */
}
因此,当我将示例脚本包装在管道 {} 中时,它起作用了。
我有一个简单的 hello world 项目,它在新的 Jenkins 安装上失败了。我正在按照 URL 中的说明进行操作:https://code-maven.com/jenkins-pipeline-hello-world
作为参考,安装了以下简单的构建管道插件:
构建管道插件 1.5.8
管道保留 运行 步骤 1.0
管道实用程序步骤 2.6.1
管道:API 2.40
管道:基本步骤 2.22
管道:构建步骤 2.13
管道:Groovy 2.85
管道:输入步骤 2.12
管道:作业 2.40
管道:保持环境步骤插件 1.0
管道:节点和进程 2.36
管道:REST API 插件 2.18
管道:SCM 步骤 2.11
管道:阶段步骤 2.5
管道:舞台视图插件 2.18
管道:步骤 API 2.23
流水线:支持APIs 3.6
可锁定资源
(这也使得我在发帖前阅读的以下链接不适用:Jenkins pipeline - No such DSL method 'build',
因此,根据我正在学习的教程,我创建了一个管道,并在配置中将以下代码放入“管道”部分:
pipeline {
agent { label 'master' }
stages {
stage('build') {
steps {
echo "Hello World!"
}
}
}
}
当我点击“立即构建”按钮时,我从控制台输出中得到以下信息:
Started by user dogzilla
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] End of Pipeline
java.lang.NoSuchMethodError: No such DSL method 'pipeline' found among steps [archive, bat, build, catchError, checkout, compareVersions, deleteDir, dir, echo, error, fileExists, findFiles, getContext, input, isUnix, junit, keepEnv, keepRunning, load, lock, mail, node, nodesByLabel, parallel, powershell, publishChecks, pwd, pwsh, readCSV, readFile, readJSON, readManifest, readMavenPom, readProperties, readYaml, retry, sh, sha1, sleep, stage, stash, step, tee, timeout, tm, tool, touch, unarchive, unstable, unstash, unzip, waitUntil, warnError, withContext, withEnv, wrap, writeCSV, writeFile, writeJSON, writeMavenPom, writeYaml, ws, zip] or symbols [all, always, apiToken, architecture, archiveArtifacts, artifactManager, batchFile, booleanParam, buildButton, buildDiscarder, buildDiscarders, caseInsensitive, caseSensitive, choice, choiceParam, clock, command, credentials, cron, crumb, defaultView, demand, disableConcurrentBuilds, disableResume, downstream, dumb, durabilityHint, envVars, envVarsFilter, file, fileParam, filePath, fingerprint, fingerprints, frameOptions, freeStyle, freeStyleJob, fromScm, fromSource, headRegexFilter, headWildcardFilter, hyperlink, hyperlinkToModels, installSource, javadoc, jdk, jdkInstaller, jnlp, jobBuildDiscarder, jobName, junitTestResultStorage, lastDuration, lastFailure, lastGrantedAuthorities, lastStable, lastSuccess, legacy, list, local, location, logRotator, loggedInUsersCanDoAnything, mailer, masterBuild, maven, maven3Mojos, mavenErrors, mavenMojos, mavenWarnings, myView, nodeProperties, none, paneStatus, parameters, password, pattern, permanent, pipelineTriggers, plainText, plugin, pollSCM, projectNamingStrategy, proxy, queueItemAuthenticator, quietPeriod, resourceRoot, retainOnlyVariables, run, runParam, schedule, scmRetryCount, scriptApproval, scriptApprovalLink, search, security, shell, simpleBuildDiscarder, slave, sourceRegexFilter, sourceWildcardFilter, sshPublicKey, standard, status, string, stringParam, swapSpace, text, textParam, timezone, tmpSpace, toolLocation, unsecured, upstream, userSeed, viewsTabBar, weather, zfs, zip] or globals [currentBuild, env, params]
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:216)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.kohsuke.groovy.sandbox.impl.Checker.call(Checker.java:163)
at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:157)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:142)
at org.kohsuke.groovy.sandbox.impl.Checker.call(Checker.java:161)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
at WorkflowScript.run(WorkflowScript:1)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
at com.cloudbees.groovy.cps.Next.step(Next.java:83)
at com.cloudbees.groovy.cps.Continuable.call(Continuable.java:174)
at com.cloudbees.groovy.cps.Continuable.call(Continuable.java:163)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access[=12=]1(SandboxContinuable.java:18)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access0(CpsThreadGroup.java:96)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.call(CpsThreadGroup.java:312)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.call(CpsThreadGroup.java:276)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService.call(CpsVmExecutorService.java:67)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService.run(SingleLaneExecutorService.java:136)
at jenkins.util.ContextResettingExecutorService.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService.run(ImpersonatingExecutorService.java:59)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
想知道为什么会失败。如果出现 java 问题,Jenkins 甚至不会启动。我已经安装了说明中的所有插件和我读过的一些故障排除链接。
我怎样才能让它工作?
您似乎缺少了一堆管道插件。确保安装“Pipeline”(ID:workflow-aggregator),它将安装其他管道缺少的插件。
https://plugins.jenkins.io/workflow-aggregator/#dependencies
有人在其他论坛上帮助我时,我看到了答案。在这里张贴以防它对其他人有用。
在https://www.jenkins.io/doc/book/pipeline/syntax/中说:
所有有效的声明式管道都必须包含在管道块中,例如:
pipeline {
/* insert Declarative Pipeline here */
}
因此,当我将示例脚本包装在管道 {} 中时,它起作用了。