use of org.jdom2.Element in project gocd by gocd.
the class GoControlLog method writeLogFile.
/**
* Writes the current build log to the appropriate directory and filename.
*/
public void writeLogFile(Date now) throws IOException {
String logFilename = decideLogfileName(now);
// Add the logDir as an info element
Element logDirElement = new Element("property");
logDirElement.setAttribute("name", "logdir");
logDirElement.setAttribute("value", new File(logDir).getAbsolutePath());
buildLog.getChild("info").addContent(logDirElement);
// Add the logFile as an info element
Element logFileElement = new Element("property");
logFileElement.setAttribute("name", "logfile");
logFileElement.setAttribute("value", logFilename);
buildLog.getChild("info").addContent(logFileElement);
File logfile = new File(logDir, logFilename);
if (LOG.isDebugEnabled()) {
LOG.debug("Writing log file [" + logfile.getAbsolutePath() + "]");
}
writeLogFile(logfile, buildLog);
}
use of org.jdom2.Element in project gocd by gocd.
the class BuildLogElement method setBuildLogHeader.
public Element setBuildLogHeader(String execCommand) {
Element target = new Element("target");
target.setAttribute("name", "exec");
build.addContent(target);
buildTask = new Element("task");
buildTask.setAttribute("name", execCommand);
target.addContent(buildTask);
return buildTask;
}
use of org.jdom2.Element in project gocd by gocd.
the class StageCctrayPresentationModelTest method shouldContainBuilds.
private void shouldContainBuilds(Element root) {
Element buildProject = findChildByName(root, "cruise :: ft :: firefox");
assertThat(buildProject, hasAttribute("activity", "Sleeping"));
assertThat(buildProject, hasAttribute("lastBuildStatus", "Success"));
assertThat(buildProject, hasAttribute("lastBuildLabel", String.valueOf(LABEL)));
assertThat(buildProject, hasAttribute("lastBuildTime", DATE_STR));
assertThat(buildProject, hasAttribute("webUrl", buildDetailUrl()));
}
use of org.jdom2.Element in project gocd by gocd.
the class StageCctrayPresentationModelTest method shouldGetGoodCctrayXml.
@Test
public void shouldGetGoodCctrayXml() throws Exception {
Element root = new Element("Projects");
cctrayXmlPresenter.toCctrayXml(root, CONTEXT_PATH);
assertThat(root.getChildren().size(), is(2));
shouldContainStage(root);
shouldContainBuilds(root);
}
use of org.jdom2.Element in project gocd by gocd.
the class GoConfigMigration method getCurrentSchemaVersion.
private int getCurrentSchemaVersion(String content) {
try {
SAXBuilder builder = new SAXBuilder();
Document document = builder.build(new ByteArrayInputStream(content.getBytes()));
Element root = document.getRootElement();
String currentVersion = root.getAttributeValue(schemaVersion) == null ? "0" : root.getAttributeValue(schemaVersion);
return Integer.parseInt(currentVersion);
} catch (Exception e) {
throw bomb(e);
}
}
Aggregations