我在Jenkins管道中有以下代码:
stage ('Question') { try { timeout(time: 1,unit: 'MINUTES') { userInput = input message: 'Choose server to publish to:',ok: '',parameters: [ [$class: 'hudson.model.ChoiceParameterDeFinition',choices: 'pc-ensureint\nother-server',description: 'Choose server to publish to:',name: 'server'] ] } } catch (err) { userInput = [server: 'pc-ensureint'] // if an error is caught set this value } } node () { println ${server} }
我正在尝试解决“ChoiceParameterDeFinition”中设置的“server”变量的问题.
当我运行构建时,我收到以下错误:
java.lang.NoSuchMethodError: No such DSL method '$' found among steps [AddInteractivePromotion,ArtifactoryGradleBuild,ArtifactoryMavenBuild,ConanAddRemote,ConanAddUser,InitConanClient,MavendescriptorStep,runconanCommand,ansiblePlaybook,archive,artifactoryDownload,artifactoryPromoteBuild,artifactoryUpload,bat,build,catchError,checkout,collectEnv,deleteDir,dir,dockerFingerprintFrom,dockerFingerprintRun,dockerPullStep,dockerPushStep,echo,emailext,emailextrecipients,envVarsForTool,error,fileExists,getArtifactoryServer,getContext,getDatabaseConnection,git,input,isUnix,library,libraryResource,load,mail,milestone,newArtifactoryServer,newBuildInfo,newGradleBuild,newMavenBuild,node,parallel,properties,publishBuildInfo,pwd,readFile,readTrusted,resolveScm,retry,script,sh,sleep,sql,stage,stash,step,svn,timeout,timestamps,tool,unarchive,unstash,validateDeclarativePipeline,waitForQualityGate,waitUntil,withContext,withCredentials,withDockerContainer,withDockerRegistry,withDockerServer,withEnv,wrap,writeFile,ws,xrayScanBuild] or symbols [all,allOf,always,ant,antFromApache,antOutcome,antTarget,any,anyOf,apiToken,architecture,archiveArtifacts,artifactManager,batchFile,booleanParam,branch,buildButton,builddiscarder,caseInsensitive,caseSensitive,choice,choiceParam,cleanWs,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,github,githubPush,gradle,hyperlink,hyperlinkToModels,installSource,jdk,jdkInstaller,jgit,jgitapache,jnlp,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,not,overrideIndexTriggers,panestatus,parameters,password,pattern,pipeline-model,pipelineTriggers,plainText,plugin,pollSCM,projectNamingStrategy,proxy,queueItemAuthenticator,quietPeriod,remotingCLI,run,runParam,schedule,scmRetryCount,search,security,shell,skipDefaultCheckout,skipStagesAfterUnstable,slave,stackTrace,standard,status,string,stringParam,swapSpace,text,textParam,tmpSpace,toolLocation,unsecured,upstream,usernameColonPassword,usernamePassword,viewsTabBar,weather,withSonarQubeEnv,zfs,zip] or globals [Artifactory,currentBuild,env,params,pipeline,scm] at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:149) at org.jenkinsci.plugins.workflow.cps.cpsScript.invokeMethod(cpsScript.java:108) at groovy.lang.GroovyObject$invokeMethod.call(UnkNown Source) 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$1.call(Checker.java:151) at org.kohsuke.groovy.sandBox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21) at org.jenkinsci.plugins.scriptsecurity.sandBox.groovy.SandBoxInterceptor.onMethodCall(SandBoxInterceptor.java:115) at org.kohsuke.groovy.sandBox.impl.Checker$1.call(Checker.java:149) at org.kohsuke.groovy.sandBox.impl.Checker.checkedCall(Checker.java:146) at org.kohsuke.groovy.sandBox.impl.Checker.checkedCall(Checker.java:123) at org.kohsuke.groovy.sandBox.impl.Checker.checkedCall(Checker.java:123) at com.cloudbees.groovy.cps.sandBox.SandBoxInvoker.methodCall(SandBoxInvoker.java:16) at WorkflowScript.run(WorkflowScript:16) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82) at sun.reflect.GeneratedMethodAccessor637.invoke(UnkNown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(UnkNown Source) at java.lang.reflect.Method.invoke(UnkNown Source) 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:74) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154) at org.jenkinsci.plugins.workflow.cps.SandBoxContinuable.access$001(SandBoxContinuable.java:18) at org.jenkinsci.plugins.workflow.cps.SandBoxContinuable$1.call(SandBoxContinuable.java:33) at org.jenkinsci.plugins.workflow.cps.SandBoxContinuable$1.call(SandBoxContinuable.java:30) at org.jenkinsci.plugins.scriptsecurity.sandBox.groovy.GroovySandBox.runInSandBox(GroovySandBox.java:108) at org.jenkinsci.plugins.workflow.cps.SandBoxContinuable.run0(SandBoxContinuable.java:30) at org.jenkinsci.plugins.workflow.cps.cpsThread.runNextChunk(cpsThread.java:165) at org.jenkinsci.plugins.workflow.cps.cpsThreadGroup.run(cpsThreadGroup.java:330) at org.jenkinsci.plugins.workflow.cps.cpsThreadGroup.access$100(cpsThreadGroup.java:82) at org.jenkinsci.plugins.workflow.cps.cpsThreadGroup$2.call(cpsThreadGroup.java:242) at org.jenkinsci.plugins.workflow.cps.cpsThreadGroup$2.call(cpsThreadGroup.java:230) at org.jenkinsci.plugins.workflow.cps.cpsVmExecutorService$2.call(cpsVmExecutorService.java:64) at java.util.concurrent.FutureTask.run(UnkNown Source) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at java.util.concurrent.Executors$RunnableAdapter.call(UnkNown Source) at java.util.concurrent.FutureTask.run(UnkNown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(UnkNown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(UnkNown Source) at java.lang.Thread.run(UnkNown Source) Finished: FAILURE
据我所知,“server”是一个groovy变量,因此我应该能够使用${}访问它.
所以我试过了:
echo ${server} print ${server} println ${server} println "${server}"
但无论我尝试什么,我都会遇到这个错误.
知道我做错了什么吗?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。