[Anthill-pro] Post Processing script
Ryan Smith
rws at urbancode.com
Mon Jul 21 09:46:52 CDT 2008
Curtis,
Here is a script that I tested parsing the revision from the populate
step on our server. You might need to change the step name or something
and this script should run in the same job. I did not test it with a
source config with multiple modules, but the logic for it is there. This
sets the revision as a property on the build request, which makes it
accessible throughout the build life when performed in a originating
workflow and visible in the web ui on the request itself.
// 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());
}
Ryan Smith
Yanko, Curtis wrote:
> Any thoughts out there on a post processing script that can parse the
> populate workspace step (SVN) and put the repo revision number into a
> build life property? The changeset thing just isn't working in a CI
> environment since it really needs multiple commits to get the right
> number.
>
> ==========
> Curtis Yanko
> Application & Developer Infrastructure Services
> Source->Build->Deploy
> W: 860.702.9059
> M: 860.881.2050
>
>
> This e-mail, including attachments, may include confidential and/or
> proprietary information, and may be used only by the person or entity to
> which it is addressed. If the reader of this e-mail is not the intended
> recipient or his or her authorized agent, the reader is hereby notified
> that any dissemination, distribution or copying of this e-mail is
> prohibited. If you have received this e-mail in error, please notify the
> sender by replying to this message and delete this e-mail immediately.
> ------------------------------------------------------------------------
>
> _______________________________________________
> Anthill-pro mailing list
> Anthill-pro at lists.urbancode.com
> http://lists.urbancode.com/mailman/listinfo/anthill-pro
>
More information about the Anthill-pro
mailing list