Skip to content
Permalink
Browse files

[FIXED JENKINS-22974] - Check for non-existent upstream builds

Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
  • Loading branch information...
oleg-nenashev committed May 13, 2014
1 parent 6b1ac53 commit 223500fbcb2da959efecc894bde3d0cd83417414
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/main/java/org/jenkinsci/plugins/builduser/BuildUser.java
@@ -15,6 +15,7 @@

import java.io.IOException;
import java.util.Map;
import javax.annotation.Nonnull;

import jenkins.model.Jenkins;

@@ -67,14 +68,16 @@ public void makeBuildVariables(AbstractBuild build,
/**
* Retrieve user cause that triggered this build and populate variables accordingly
*/
private void makeUserBuildVariables(Run build, Map<String, String> variables) {
private void makeUserBuildVariables(@Nonnull Run build, @Nonnull Map<String, String> variables) {

// If build has been triggered form an upstream build, get UserCause from there to set user build variables
Cause.UpstreamCause upstreamCause = (Cause.UpstreamCause) build.getCause(Cause.UpstreamCause.class);
if (upstreamCause != null) {
Job job = Jenkins.getInstance().getItemByFullName(upstreamCause.getUpstreamProject(), Job.class);
Run upstream = job.getBuildByNumber(upstreamCause.getUpstreamBuild());
makeUserBuildVariables(upstream, variables);
if (upstream != null) {
makeUserBuildVariables(upstream, variables);
}
}

// set BUILD_USER_NAME to fixed value if the build was triggered by a change in the scm

1 comment on commit 223500f

@xasx

This comment has been minimized.

Copy link

commented on 223500f Aug 26, 2014

Should really be released, please.

https://issues.jenkins-ci.org/browse/JENKINS-24439

Please sign in to comment.
You can’t perform that action at this time.