1 year ago
#65651
mario
Jenkins binding when using shared libraries
I have a declarative multibranch pipeline in Jenkins that uses shared libraries. In my shared library I have a global variable say gb1.groovy where I call it from a steps using:
gb1(binding)
Inside gb1.groovy I do code similar to:
Map x = [a: 1, b: 2]
binding.variables.put('x',x)
Later on in my pipeline I access variable x and I have access to the Map with all their values. The problem comes when I call a second global variable say gb2(). Inside gb2.groovy, the binding that was done in gb1 for x is not available (I get an error). However, the env binding done by Jenkins is available in gb2.
Can any shed some light as why this is happening and what I could do to make x available in gb2 (short of passing the binding and extracting it which is what I am doing today).
jenkins
groovy
shared-libraries
0 Answers
Your Answer