I want to detect job build cause which is trigger by Artifactory plugin. what should I write for cause statement?
I know to detect user, time, scm, or upstream trigger job. It as follows:
//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;
I expect some command like:
artifactorCause = upStreamBuild.getCause(hudson.triggers.ArtifactoryTrigger.ArtifactoryTriggerCause)
so I can have a short description of the trigger.
Basing on this javadoc I would say
artifactoryCause = upStreamBuild.getCause(org.jfrog.hudson.trigger.ArtifactoryCause)