79374231

Date: 2025-01-21 11:43:41
Score: 1
Natty:
Report link

Building on @elouan-keryell-even 's answer, you can create a function in a shared library to wrap the check, like this:

@NonCPS
def getCurrentUsername() {
    String userId
    if(currentBuild.upstreamBuilds){
        userId = currentBuild.upstreamBuilds[0].getBuildCauses()[0].userId
    } else {
        userId = currentBuild.getBuildCauses()[0].userId
    }    
    return userId.toLowerCase().trim()
}

Then in your Jenkinsfile you can do:
getCurrentUsername()

Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @elouan-keryell-even
  • Low reputation (0.5):
Posted by: kozone