Skip to content

Commit

Permalink
[FIXED JENKINS-22974] - Check for non-existent upstream builds
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
  • Loading branch information
oleg-nenashev committed May 13, 2014
1 parent 6b1ac53 commit 223500f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/org/jenkinsci/plugins/builduser/BuildUser.java
Expand Up @@ -15,6 +15,7 @@

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

import jenkins.model.Jenkins;

Expand Down Expand Up @@ -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
Expand Down

1 comment on commit 223500f

@xasx
Copy link

@xasx xasx commented on 223500f Aug 26, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should really be released, please.

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

Please sign in to comment.