How to get the BUILD_USER in Jenkins when job triggered by timer?

后端 未结 14 1540
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-09 03:01

I wanted to show the user who triggered a Jenkins job in the post job email. This is possible by using the plugin Build User Vars Plugin and the env variable

相关标签:
14条回答
  • 2020-12-09 03:32

    I have written a groovy script to extract the started by which would correctly get the source, regardless if user, scm or timer (could add more). It would recursively navigate the build tree to get the "original" 'started by' cause https://github.com/Me-ion/jenkins_build_trigger_cause_extractor

    0 讨论(0)
  • 2020-12-09 03:33

    I'm using a combination of the 'Execute Shell' and 'Env Inject' plugin as follows:

    1. Create an 'Execute Shell' build step that uses shell parameter substitution to write default the value and echo that value into a file. Example highlighted in screen shot below.
    2. Use the 'Env Inject' file to read that file as properties to set.

    0 讨论(0)
提交回复
热议问题