我想检测由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)
所以我可以简短地描述一下触发器。
答案 0 :(得分:0)
我会说this javadoc为基础
artifactoryCause = upStreamBuild.getCause(org.jfrog.hudson.trigger.ArtifactoryCause)