Jenkins Groovy: What triggered the build

前端 未结 1 1548
天命终不由人
天命终不由人 2020-12-18 13:06

I was thinking of using a Groovy script for my build job in Jenkins because I have some conditions to check for that might need access to Jenkins API.

Is it possible

相关标签:
1条回答
  • 2020-12-18 13:20

    I have something similar - I wanted to get the user who triggered the build, this is my code:

    for (cause in bld.getCauses()) {
        if (cause instanceof Cause.UserIdCause) {
            return cause.getUserName()
        }
    }
    

    (bld is subtype of Run)

    So, you can get the causes for your build, and check for their type.

    See the different types at Cause javadoc http://javadoc.jenkins-ci.org/hudson/model/Cause.html

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