如何在 jenkins 管道项目(groovy 脚本)中检测由人工触发器引起的触发器?

How to detect trigger cause by artifactory trigger in jenkins pipeline project (groovy script)?

我想检测由 Artifactory 插件触发的作业构建原因。原因陈述应该写什么?

我知道检测用户、时间、scm 或上游触发器作业。如下:

    //Check if the build was triggered by SCM change
    scmCause = upStreamBuild.getCause(hudson.triggers.SCMTrigger.SCMTriggerCause)
    if (scmCause != null) {
        return scmCause.getShortDescription()
    }

    //Check if the build was triggered by timer
    timerCause = upStreamBuild.getCause(hudson.triggers.TimerTrigger.TimerTriggerCause)
    if (timerCause != null) {
        return timerCause.getShortDescription()
    }

    //Check if the build was triggered by some jenkins project(job)
    upstreamcause = upStreamBuild.getCause(hudson.model.Cause.UpstreamCause.class)
    if (upstreamcause != null) {
        job = Jenkins.getInstance().getItemByFullName(upstreamcause.getUpstreamProject(), hudson.model.Job.class)
        if (job != null) {
            upstream = job.getBuildByNumber(upstreamcause.getUpstreamBuild())
            if (upstream != null) {
                return upstream
            }
        }
    }
    return;

我希望有这样的命令:

artifactorCause = upStreamBuild.getCause(hudson.triggers.ArtifactoryTrigger.ArtifactoryTriggerCause)

所以我可以对触发器进行简短描述。

基于this javadoc我会说

artifactoryCause = upStreamBuild.getCause(org.jfrog.hudson.trigger.ArtifactoryCause)