user3141805
user3141805

Reputation: 23

Display the username who ran the build in Build History

How can I display the username who executed the build next to the build number? like in the image below enter image description here

Upvotes: 1

Views: 1647

Answers (5)

rohit
rohit

Reputation: 1

Install Build trigger Badge Plugin:
Jenkins Plugin

Upvotes: 0

andaji
andaji

Reputation: 81

  1. Add Groovy Postbuild and user build vars plugin

  2. edit job configure,check 【Set jenkins user build variables】,then you can get env variables 'BUILD_USER'

  3. Post-build Actions, add 【Groovy Postbuild】, Groovy Script change to

    manager.addShortText(manager.envVars['BUILD_USER'])

Upvotes: 0

Paul Verest
Paul Verest

Reputation: 64031

See, install and enable for the job https://plugins.jenkins.io/build-user-vars-plugin/

Then change name of build using BUILD_USER_ID variable, like

#${BUILD_NUMBER}: ${GIT_REVISION,length=8} (${GIT_BRANCH}) by ${BUILD_USER_ID}

Upvotes: 0

Doyniish
Doyniish

Reputation: 11

Try entering Started by ([\S]+) in the section "Post-build Actions -> Set build description -> Regular expression" of your job config.

Upvotes: 1

max.ivanch
max.ivanch

Reputation: 349

You can add user name to build description.

currentBuild.description = currentBuild.getBuildCauses().shortDescription[0]

Then you will get something like bellow

* #1 Feb 24, 2020 10:00 AM
| Started by user max

If you want use user only then

currentBuild.description = currentBuild.getBuildCauses().userId[0]

Data structure is :

[{"_class":"hudson.model.Cause$UserIdCause","shortDescription":"Started by user max","userId":"max","userName":"max"}]

Upvotes: 0

Related Questions