It is good of what I thought. Thank you for the confirmation. Le mercredi 4 avril 2018 09:24:18 UTC+11, Steven Foster a écrit : > > I think with the declarative syntax all of the "scaffolding" (stages, > post, when) bits have to be set in stone. > > This recent thread might be slightly relevant > https://groups.google.com/forum/#!topic/jenkinsci-users/E-3O1rHWkdM > > On Tuesday, April 3, 2018 at 11:14:51 PM UTC+1, Arnaud Brunet wrote: >> >> Hi guys, >> >> I try to make a pipeline script with dynamic stages. >> >> In static way, I do >> >> pipeline { >> agent any >> options { >> timestamps() >> } >> stages { >> stage('Init') { >> steps { >> script { >> echo "TOTO" >> } >> } >> } >> } >> } >> >> but I want my stages to be dynamic, something like that : >> >> def jobStages = [ >> 'init': { >> echo "Init" >> } >> ] >> >> pipeline { >> agent any >> options { >> timestamps() >> } >> stages { >> jobStages.each { name, closure -> >> stage(name) { >> steps { >> script { >> closure.call() >> } >> } >> } >> } >> } >> } >> >> But Jenkins doesn't like it : >> >> /var/lib/jenkins/jobs/AXI-TEST-Pipeline >> Script/builds/79/libs/jenkins-shared-libs/vars/standardBuild.groovy: 27: >> Expected a stage @ line 27, column 13. >> jobStages.each { name, closure -> >> ^ >> >> /var/lib/jenkins/jobs/AXI-TEST-Pipeline >> Script/builds/79/libs/jenkins-shared-libs/vars/standardBuild.groovy: 26: No >> stages specified @ line 26, column 9. >> stages { >> ^ >> >> 2 errors >> >> at >> org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310) >> at >> org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085) >> at >> org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603) >> at >> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581) >> at >> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558) >> at >> groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) >> at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) >> at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:254) >> at groovy.lang.GroovyClassLoader.recompile(GroovyClassLoader.java:761) >> at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:718) >> at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:787) >> at java.lang.ClassLoader.loadClass(ClassLoader.java:411) >> at >> org.jenkinsci.plugins.workflow.cps.CpsGroovyShell$TimingLoader.loadClass(CpsGroovyShell.java:160) >> at java.lang.ClassLoader.loadClass(ClassLoader.java:411) >> at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:677) >> at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:787) >> at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:775) >> at >> org.jenkinsci.plugins.workflow.cps.global.UserDefinedGlobalVariable.getValue(UserDefinedGlobalVariable.java:54) >> at >> org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:99) >> at sun.reflect.GeneratedMethodAccessor500.invoke(Unknown Source) >> at >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >> at java.lang.reflect.Method.invoke(Method.java:483) >> 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$1.call(Checker.java:157) >> at >> org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23) >> at >> org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:133) >> at >> org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:120) >> at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155) >> at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159) >> at >> com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17) >> at WorkflowScript.run(WorkflowScript:3) >> 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.GeneratedMethodAccessor232.invoke(Unknown Source) >> at >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >> at java.lang.reflect.Method.invoke(Method.java:483) >> 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$1.call(Continuable.java:174) >> at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163) >> at >> org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122) >> at >> org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261) >> at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163) >> at >> org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19) >> at >> org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35) >> at >> org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32) >> at >> org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108) >> at >> org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32) >> at >> org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174) >> at >> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:331) >> at >> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:82) >> at >> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:243) >> at >> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:231) >> at >> org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64) >> at java.util.concurrent.FutureTask.run(FutureTask.java:266) >> at >> hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131) >> at >> jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) >> 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:1142) >> at >> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) >> at java.lang.Thread.run(Thread.java:745) >> Finished: FAILURE >> >> >> Is there a way to do this ? >> >> Regards, >> Arnaud. >> >> >>
-- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5c1e678f-7bb1-4973-a5cb-48f066d356c6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
