jervis
jervis copied to clipboard
Pass global environment variables from .jervis.yml file to pipeline_jenkinsfile
I need to pass some variable from .jervis.yml
to Jenkinsfile
, but can't figure out how to do that.
I was trying to set variable in env
section:
env:
- MY_VAR=xyz
But can't access that variable in Jenkinsfile
def MY_VAR = env.MY_VAR ?: 'default'
sh "echo $MY_VAR"
Each time it shows default
At this time, it's not designed that way. I have that planned for secrets (ref https://github.com/samrocketman/jervis/issues/103) but haven't really thought about environment variables.
One of the challenges being that env
is supported in matrix builds. I suppose I could allow:
env:
global:
- MY_VAR=xyz
From the environment matrix to pass variables. More research would be required to support something like this.