Skip to content

Commit

Permalink
[JENKINS-13879] use the latest submitted depot change instead of coun…
Browse files Browse the repository at this point in the history
…ter when there are no changes to record
  • Loading branch information
Rob Petti committed May 23, 2012
1 parent 9fd85bc commit 33720a1
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/main/java/hudson/plugins/perforce/PerforceSCM.java
Expand Up @@ -816,14 +816,25 @@ public boolean checkout(AbstractBuild build, Launcher launcher,
if (p4Label != null && !p4Label.trim().isEmpty()) {
newestChange = depot.getChanges().getHighestLabelChangeNumber(p4workspace, p4Label.trim(), p4WorkspacePath);
} else {
String counterName;
if (p4Counter != null && !updateCounterValue)
if (p4Counter != null && !updateCounterValue) {
//use a counter
String counterName;
counterName = substituteParameters(this.p4Counter, build);
else
counterName = "change";

Counter counter = depot.getCounters().getCounter(counterName);
newestChange = counter.getValue();
Counter counter = depot.getCounters().getCounter(counterName);
newestChange = counter.getValue();
} else {
//use the latest submitted change from depot
try {
List<Integer> depotChanges = depot.getChanges().getChangeNumbers("//...", 0, 1);
if (depotChanges != null && depotChanges.size() > 0) {
newestChange = depotChanges.get(0);
}
} catch (PerforceException e) {
//fall back onto 'change' counter value
Counter counter = depot.getCounters().getCounter("change");
newestChange = counter.getValue();
}
}
}

if (build instanceof MatrixRun) {
Expand Down

0 comments on commit 33720a1

Please sign in to comment.