Skip to content

Commit

Permalink
Merge pull request jenkinsci#4168 from Egor18/fixCounter
Browse files Browse the repository at this point in the history
Fix counter which is not updated in the loop
  • Loading branch information
oleg-nenashev authored Aug 30, 2019
2 parents 2454cbd + 10aebc5 commit 9e8df8a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions core/src/main/java/hudson/model/AbstractProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -553,17 +553,15 @@ private AbstractBuild getBuildForDeprecatedMethods() {
* @return null if no such build exists.
*/
public final R getSomeBuildWithWorkspace() {
int cnt=0;
for (R b = getLastBuild(); cnt<5 && b!=null; b=b.getPreviousBuild()) {
for (R b = getLastBuild(); b != null; b = b.getPreviousBuild()) {
FilePath ws = b.getWorkspace();
if (ws!=null) return b;
}
return null;
}

private R getSomeBuildWithExistingWorkspace() throws IOException, InterruptedException {
int cnt=0;
for (R b = getLastBuild(); cnt<5 && b!=null; b=b.getPreviousBuild()) {
for (R b = getLastBuild(); b != null; b = b.getPreviousBuild()) {
FilePath ws = b.getWorkspace();
if (ws!=null && ws.exists()) return b;
}
Expand Down

0 comments on commit 9e8df8a

Please sign in to comment.