How to set an environment variable programmatically in Jenkins/Hudson?

后端 未结 2 1453
猫巷女王i
猫巷女王i 2020-12-09 17:39

I have two scripts in the pre-build step in a Jenkins job, the first one a perl script, the second a system groovy script using the groovy plugin. I need information from th

2条回答
  •  情歌与酒
    2020-12-09 18:10

    Using EnvInject Plugin from job configuration you should use Inject environment variables to the build process / Evaluated Groovy script.

    Depending on the setup you may execute Groovy or shell command and save it in map containing environment variables:

    Example

    By either getting command result with execute method:

    return [DATE: 'date'.execute().text]
    

    or with Groovy equivalent if one exists:

    return [DATE: new Date()]
    

提交回复
热议问题