(→AHPSCRIPTS-41)
|
(→AHPSCRIPTS-40)
|
Line 846: | |||
// continue processing the other dependencies .... </pre> | // continue processing the other dependencies .... </pre> | ||
+ | = Parse SVN Revision Number from Checkout Output = | ||
+ | ==== AHPSCRIPTS-66 ==== | ||
+ | <pre>// looking for "Checked out revision 19642." | ||
+ | stepName = "Populate Workspace"; | ||
+ | revisionStart = "Checked out revision "; | ||
+ | revisionEnd = "."; | ||
+ | latestRevision = 0; | ||
+ | jobTrace = JobTraceLookup.getCurrent(); | ||
+ | steps = jobTrace.getStepTraceArray(); | ||
+ | step = null; | ||
+ | for (int s=0; s<steps.length; s++) { | ||
+ | if (stepName.equals(steps[s].getName())) { | ||
+ | step = steps[s]; | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | commands = step.getCommandTraceArray(); | ||
+ | for (int c=0; c<commands.length; c++) { | ||
+ | if (commands[c].getName().startsWith("populate-workspace")) { | ||
+ | log = LogHelper.getOutput(commands[c]); | ||
+ | start = log.lastIndexOf(revisionStart); | ||
+ | if (start < 0) { | ||
+ | commandOutput.println("Revision not found in " + commands[c].getName()); | ||
+ | } | ||
+ | else { | ||
+ | start += revisionStart.length(); | ||
+ | log = log.substring(start); | ||
+ | end = log.indexOf(revisionEnd); | ||
+ | if (end < 0) { | ||
+ | commandOutput.println("Revision not found in " + commands[c].getName()); | ||
+ | } | ||
+ | else { | ||
+ | rev = Long.parseLong(log.substring(0, end).trim()); | ||
+ | |||
+ | if (rev > latestRevision) { | ||
+ | latestRevision = rev; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | if (latestRevision > 0) { | ||
+ | BuildRequestLookup.getCurrent().setProperty("svn.revision", String.valueOf(latestRevision)); | ||
+ | commandOutput.println("Found revision " + latestRevision); | ||
+ | } | ||
+ | else { | ||
+ | commandOutput.println("Revision not found in " + jobTrace.getName()); | ||
+ | } | ||
+ | </pre> |