Skip to content

Commit 3581099

Browse files
authored
Fix declarative pipeline example in README
The current example did not work (copy/paste in Jenkins pipeline => error) This PR proposes a working example. Details : Jenkins version : 2.190.1 Parameterized Scheduler : 0.8 Error with current example : ``` Running in Durability level: MAX_SURVIVABILITY org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 9: Triggers definitions cannot have blocks @ line 9, column 9. parameterizedCron { ^ 1 error 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.GroovyShell.parseClass(GroovyShell.java:688) at groovy.lang.GroovyShell.parse(GroovyShell.java:700) at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142) at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127) at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561) at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522) at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:327) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429) Finished: FAILURE ```
1 parent 3c44335 commit 3581099

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,18 @@ pipeline {
6060
string(name: 'GREETING', defaultValue: 'Hello', description: 'How shall we greet?')
6161
}
6262
triggers {
63-
cron('* * * * *')
64-
parameterizedCron {
65-
parameterizedSpecification('''
66-
# leave spaces where you want them around the parameters. They'll be trimmed.
67-
# we let the build run with the default name
68-
*/2 * * * * %GREETING=Hola;PLANET=Pluto
69-
*/3 * * * * %PLANET=Mars
63+
parameterizedCron('''
64+
# leave spaces where you want them around the parameters. They'll be trimmed.
65+
# we let the build run with the default name
66+
*/2 * * * * %GREETING=Hola;PLANET=Pluto
67+
*/3 * * * * %PLANET=Mars
7068
''')
71-
}
7269
}
7370
stages {
7471
stage('Example') {
7572
steps {
76-
echo "${GREETING} ${PLANET}"
77-
script { currentBuild.description = "${GREETING} ${PLANET}" }
73+
echo "${params.GREETING} ${params.PLANET}"
74+
script { currentBuild.description = "${params.GREETING} ${params.PLANET}" }
7875
}
7976
}
8077
}

0 commit comments

Comments
 (0)