groovy - Get input approver user name in Jenkins Workflow plugin -


i trying userid approved "input" step in workflow jenkins groovy script. below sample script

node('node1'){     stage "test"      input  message: 'test' } 

in workflow ui if person hits "thumbs up" want print userid in log. dont see option it.

def cause = currentbuild.rawbuild.getcause(cause.useridcause) cause.userid  

will print person started build. have googled days not finding anything. here appreciated :)

this jira issue describes how work going forward, still open.

in meantime, approach of getting latest approveraction via build actions api suggested on #jenkins irc , should work, note it's not sandbox safe.

something along lines of below getting recent approver:

@noncps def getlatestapprover() {    def latest = null     // returns copyonwritearraylist, safe iteration    def acts = currentbuild.rawbuild.getallactions()    (act in acts) {        if (act instanceof org.jenkinsci.plugins.workflow.support.steps.input.approveraction) {            latest = act.userid        }    }    return latest } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -