دنبال کننده ها

۱۳۹۶ تیر ۱۳, سه‌شنبه

jenkins - Globals in environment variable declaration in a declarative pipeline

[ad_1]



It is possible to use globals in a declarative pipeline?



The following example works as expected.



#!groovy
@Library("SomeSharedLibrary@1.0.0") _
pipeline
agent none
environment
FOO = "World"
BAR = "Hello $FOO!"

stages
stage("Simple test")
steps
echo BAR //prints "Hello World!"






The following code fails. It uses a global var defined in ASharedLibrary.



#!groovy
@Library("ASharedLibrary@1.0.0") _
pipeline
agent none
environment
FOO = "World"
BAR = glovalvar.greeter(FOO)

stages
stage("Simple test")
steps
echo BAR //fails telling that BAR is not defined.






Any idea? am I doing something wrong?




[ad_2]

لینک منبع