-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-70726] Build result scoring skipped on pipeline jobs #65
base: main
Are you sure you want to change the base?
[JENKINS-70726] Build result scoring skipped on pipeline jobs #65
Conversation
oh, i also had a second freebie commit for just some random code-cleanup/typos. |
...m/jenkins/plugins/scoringloadbalancer/rules/BuildResultScoringRule/help-scoreForFailure.html
Outdated
Show resolved
Hide resolved
src/test/java/jp/ikedam/jenkins/plugins/scoringloadbalancer/ScoringLoadBalancerTest.java
Outdated
Show resolved
Hide resolved
3844c32
to
89e9d4f
Compare
BuildResult scoring always returned 0 for pipeline jobs, this change hopefully supports both freestyle and pipeline jobs by properly checking the class type
89e9d4f
to
0d1518c
Compare
WorkflowRun pipelinebuild = null; | ||
|
||
if ((subtask instanceof AbstractProject)) { | ||
AbstractProject<?, ?> project = (AbstractProject<?, ?>) subtask; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AbstractProject<?, ?> project = (AbstractProject<?, ?>) subtask; | |
var project = (AbstractProject<?, ?>) subtask; |
Use var
where possible
AbstractProject<?, ?> project = (AbstractProject<?, ?>) subtask; | ||
freestylebuild = project.getLastBuild(); | ||
} else if (subtask != null) { | ||
Executable qexec = subtask.getOwnerExecutable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Executable qexec = subtask.getOwnerExecutable(); | |
var qexec = subtask.getOwnerExecutable(); |
} else if (subtask != null) { | ||
Executable qexec = subtask.getOwnerExecutable(); | ||
if (qexec != null && (qexec.getParent() instanceof WorkflowJob)) { | ||
WorkflowJob wfj = (WorkflowJob) qexec.getParent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WorkflowJob wfj = (WorkflowJob) qexec.getParent(); | |
var wfj = (WorkflowJob) qexec.getParent(); |
result = freestylebuild.getResult(); | ||
freestylebuild = freestylebuild.getPreviousBuild(); | ||
} else if (pipelinebuild != null) { | ||
FlowExecution fexec = pipelinebuild.getExecution(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FlowExecution fexec = pipelinebuild.getExecution(); | |
var fexec = pipelinebuild.getExecution(); |
continue; | ||
} | ||
|
||
FlowGraphWalker fgw = new FlowGraphWalker(fexec); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FlowGraphWalker fgw = new FlowGraphWalker(fexec); | |
var fgw = new FlowGraphWalker(fexec); |
FlowGraphWalker fgw = new FlowGraphWalker(fexec); | ||
for (FlowNode fn : fgw) { | ||
if (fn instanceof StepStartNode) { | ||
WorkspaceAction action = (WorkspaceAction) fn.getAction(WorkspaceAction.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WorkspaceAction action = (WorkspaceAction) fn.getAction(WorkspaceAction.class); | |
var action = (WorkspaceAction) fn.getAction(WorkspaceAction.class); |
nodesScore.addScore(node, getScoreForFailure() * scale); | ||
nodeSet.remove(node); | ||
} else if (Result.UNSTABLE == build.getResult()) { | ||
} else if (Result.UNSTABLE == result) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test case to cover code?
Added support for Build Result scoring on pipeline jobs (was always returning 0)
closes #64
https://issues.jenkins.io/browse/JENKINS-70726
Testing done
Verified that jobs were scored based on Build Result when the job was pipeline using the logging feature. Did not regression test that freestyle jobs continue to work.
Submitter checklist