jervis icon indicating copy to clipboard operation
jervis copied to clipboard

Pass global environment variables from .jervis.yml file to pipeline_jenkinsfile

Open tairov opened this issue 6 years ago • 5 comments

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

tairov avatar May 08 '18 19:05 tairov

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.

samrocketman avatar May 08 '18 22:05 samrocketman