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
Post a Comment