Source:
public Document toXml(XmlWriterContext writerContext) throws DocumentException, IOException { DOMElement root = new DOMElement("job"); root.addAttribute("name", jobInstance.getName()); Document document = new DOMDocument(root); root.addElement("link").addAttribute("rel", "self").addAttribute("href", httpUrl(writerContext.getBaseUrl())); JobIdentifier identifier = jobInstance.getIdentifier(); root.addElement("id").addCDATA(identifier.asURN()); String pipelineName = identifier.getPipelineName(); StageIdentifier stageId = identifier.getStageIdentifier(); root.addElement("pipeline").addAttribute("name", pipelineName) .addAttribute("counter", String.valueOf(stageId.getPipelineCounter())) .addAttribute("label", stageId.getPipelineLabel()); root.addElement("stage").addAttribute("name", stageId.getStageName()).addAttribute("counter", stageId.getStageCounter()).addAttribute("href", StageXmlViewModel.httpUrlFor( writerContext.getBaseUrl(), jobInstance.getStageId())); root.addElement("result").addText(jobInstance.getResult().toString()); root.addElement("state").addText(jobInstance.getState().toString()); Element properties = root.addElement("properties"); for (Property property : writerContext.propertiesForJob(jobInstance.getId())) { properties.addElement("property").addAttribute("name", property.getKey()).addCDATA(property.getValue()); } root.addElement("agent").addAttribute("uuid", jobInstance.getAgentUuid()); root.addComment("artifacts of type `file` will not be shown. See <LINK_0>"); Element artifacts = root.addElement("artifacts"); artifacts.addAttribute("baseUri", writerContext.artifactBaseUrl(identifier)).addAttribute("pathFromArtifactRoot", writerContext.artifactRootPath(identifier)); JobPlan jobPlan = writerContext.planFor(identifier); for (ArtifactPlan artifactPlan : jobPlan.getArtifactPlans()) { artifacts.addElement("artifact").addAttribute("src", artifactPlan.getSrc()).addAttribute("dest", artifactPlan.getDest()).addAttribute("type", artifactPlan.getArtifactType().toString()); } root.addComment("resources are now intentionally left blank. See <LINK_0>"); root.addElement("resources"); root.addComment("environmentvariables are now intentionally left blank. See <LINK_0>"); root.addElement("environmentvariables"); return document; }

Target:
public Document toXml(XmlWriterContext writerContext) throws DocumentException, IOException { DOMElement root = new DOMElement("job"); root.addAttribute("name", jobInstance.getName()); Document document = new DOMDocument(root); root.addElement("link").addAttribute("rel", "self").addAttribute("href", httpUrl(writerContext.getBaseUrl())); JobIdentifier identifier = jobInstance.getIdentifier(); root.addElement("id").addCDATA(identifier.asURN()); String pipelineName = identifier.getPipelineName(); StageIdentifier stageId = identifier.getStageIdentifier(); root.addElement("pipeline").addAttribute("name", pipelineName) .addAttribute("counter", String.valueOf(stageId.getPipelineCounter())) .addAttribute("label", stageId.getPipelineLabel()); root.addElement("stage").addAttribute("name", stageId.getStageName()).addAttribute("counter", stageId.getStageCounter()).addAttribute("href", StageXmlViewModel.httpUrlFor( writerContext.getBaseUrl(), jobInstance.getStageId())); root.addElement("result").addText(jobInstance.getResult().toString()); root.addElement("state").addText(jobInstance.getState().toString()); Element properties = root.addElement("properties"); for (Property property : writerContext.propertiesForJob(jobInstance.getId())) { properties.addElement("property").addAttribute("name", property.getKey()).addCDATA(property.getValue()); } root.addElement("agent").addAttribute("uuid", jobInstance.getAgentUuid()); root.addComment("artifacts of type `file` will not be shown. See <LINK_0>"); Element artifacts = root.addElement("artifacts"); artifacts.addAttribute("baseUri", writerContext.artifactBaseUrl(identifier)).addAttribute("pathFromArtifactRoot", writerContext.artifactRootPath(identifier)); JobPlan jobPlan = writerContext.planFor(identifier); for (ArtifactPlan artifactPlan : jobPlan.getArtifactPlansOfType(ArtifactType.unit)) { artifacts.addElement("artifact").addAttribute("src", artifactPlan.getSrc()).addAttribute("dest", artifactPlan.getDest()).addAttribute("type", artifactPlan.getArtifactType().toString()); } root.addComment("resources are now intentionally left blank. See <LINK_0>"); root.addElement("resources"); root.addComment("environmentvariables are now intentionally left blank. See <LINK_0>"); root.addElement("environmentvariables"); return document; }