Hi Juan,
I was trying to implement the same concept into my shared library activities to handle repetition of code.
I am using Jenkins v2.105 and I see some problems when I shifted my stage definition into a shared-library call as below:
ln#01 pipeline { ln#02 stages { ln#03 stage('1') { ln#04 println "I am in stage 1" ln#05 } ln#06 ln#07 stage('2') { ln#08 println "I am in stage 2" ln#09 } ln#10 } ln#11 }
ln#01 pipeline { ln#02 stages { ln#03 stage('1') { ln#04 println "I am in stage 1" ln#05 } ln#06 ln#07 dynamicStage{ ln#08 param = '2' ln#09 } ln#10 } ln#11 }
vars/dynamicStage.groovy ln#01 def call(body) { ln#02 def config = [:] ln#03 body.resolveStrategy = Closure.DELEGATE_FIRST ln#04 body.delegate = config ln#05 body() ln#06 ln#07 stage('Dynamic Stage') { ln#08 println "I am in stage ${config.param}" ln#09 } ln#01 ln#11 }
I am in stage 1 I am in stage 2
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 07: Expected a stage @ line 07, column [ColumnNumber]. dynamicStage {
Is it something that the Jenkins v2.105 doesn't support this?
Any Luck on the shared library that you have implemented?
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Juan,
I was trying to implement the same concept into my shared library activities to handle repetition of code.
I am using Jenkins v2.105 and I see some problems when I shifted my stage definition into a shared-library call as below:
Before Update:
ln#01 pipeline {
ln#02 stages {
ln#03 stage('1') {
ln#04 println "I am in stage 1"
ln#05 }
ln#06
ln#07 stage('2') {
ln#08 println "I am in stage 2"
ln#09 }
ln#10 }
ln#11 }
After Update:
ln#01 pipeline {
ln#02 stages {
ln#03 stage('1') {
ln#04 println "I am in stage 1"
ln#05 }
ln#06
ln#07 dynamicStage{
ln#08 param = '2'
ln#09 }
ln#10 }
ln#11 }
vars/dynamicStage.groovy
ln#01 def call(body) {
ln#02 def config = [:]
ln#03 body.resolveStrategy = Closure.DELEGATE_FIRST
ln#04 body.delegate = config
ln#05 body()
ln#06
ln#07 stage('Dynamic Stage') {
ln#08 println "I am in stage ${config.param}"
ln#09 }
ln#01
ln#11 }
Expected Behaviour:
I am in stage 1
I am in stage 2
Execution Result:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 07: Expected a stage @ line 07, column [ColumnNumber].
dynamicStage {
Is it something that the Jenkins v2.105 doesn't support this?
Any Luck on the shared library that you have implemented?