Skip to content

Commit

Permalink
[JENKINS-40477] - get rid of ClassCastException
Browse files Browse the repository at this point in the history
  • Loading branch information
fredg02 committed Feb 22, 2017
1 parent c6211d0 commit 550a456
Showing 1 changed file with 9 additions and 6 deletions.
Expand Up @@ -25,6 +25,7 @@

import jenkins.model.Jenkins;

import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;
Expand All @@ -44,14 +45,16 @@ public LastBuildNodeColumn() {

public String getLastBuildNode(Job<?, ?> job) {
Run<?, ?> lastBuild = job.getLastBuild();
if (lastBuild == null) {
if (lastBuild == null || lastBuild instanceof WorkflowRun) {
return null;
} else if (lastBuild instanceof AbstractBuild<?, ?>) {

This comment has been minimized.

Copy link
@jglick

jglick Feb 22, 2017

Member

No need to depend on WorkflowRun. Suffices to say

if (lastBuild instanceof AbstractBuild) {
    // …
} else {
    return null;
}

This comment has been minimized.

Copy link
@fredg02

fredg02 Mar 1, 2017

Author Member

Thanks. Late night commits can be bad....

Node builtOn = ((AbstractBuild<?, ?>) lastBuild).getBuiltOn();
if (builtOn instanceof Jenkins) {
return "master";
}
return builtOn.getDisplayName();
}
Node builtOn = ((AbstractBuild<?, ?>) lastBuild).getBuiltOn();
if (builtOn instanceof Jenkins) {
return "master";
}
return builtOn.getDisplayName();
return null;
}

@Extension
Expand Down

0 comments on commit 550a456

Please sign in to comment.