use of com.thoughtworks.go.config.ArtifactPlan in project gocd by gocd.
the class ArtifactPlanTest method shouldProvideAppendFilePathToDestWhenUsingSingleStarToMatchFile.
@Test
public void shouldProvideAppendFilePathToDestWhenUsingSingleStarToMatchFile() {
ArtifactPlan artifactPlan = new ArtifactPlan("test/a/b/*.log", "logs");
assertThat(artifactPlan.destURL(new File("pipelines/pipelineA"), new File("pipelines/pipelineA/test/a/b/a.log")), is("logs"));
}
use of com.thoughtworks.go.config.ArtifactPlan in project gocd by gocd.
the class JobXmlViewModel method toXml.
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());
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());
}
Element resources = root.addElement("resources");
for (Resource resource : jobPlan.getResources()) {
resources.addElement("resource").addText(resource.getName());
}
Element envVars = root.addElement("environmentvariables");
for (EnvironmentVariableConfig environmentVariableConfig : jobPlan.getVariables()) {
envVars.addElement("variable").addAttribute("name", environmentVariableConfig.getName()).addCDATA(environmentVariableConfig.getDisplayValue());
}
return document;
}
use of com.thoughtworks.go.config.ArtifactPlan in project gocd by gocd.
the class ArtifactPlanRepository method saveCopyOf.
public ArtifactPlan saveCopyOf(long jobId, ArtifactPlan artifactPlan) {
ArtifactPlan copyOfArtifactPlan = new ArtifactPlan(artifactPlan);
copyOfArtifactPlan.setBuildId(jobId);
save(copyOfArtifactPlan);
return copyOfArtifactPlan;
}
use of com.thoughtworks.go.config.ArtifactPlan in project gocd by gocd.
the class ArtifactPlanRepositoryIntegrationTest method shouldSaveACopyOfAnArtifactPlan.
@Test
public void shouldSaveACopyOfAnArtifactPlan() {
// Arrange
JobInstance firstJobInstance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME + "1"));
JobInstance secondJobInstance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME + "2"));
ArtifactPlan artifactPlan = new ArtifactPlan("src", "dest");
// Act
ArtifactPlan artifactPlanOfFirstJob = artifactPlanRepository.saveCopyOf(firstJobInstance.getId(), artifactPlan);
ArtifactPlan artifactPlanOfSecondJob = artifactPlanRepository.saveCopyOf(secondJobInstance.getId(), artifactPlan);
// Assert
List<ArtifactPlan> firstJobArtifactPlans = artifactPlanRepository.findByBuildId(firstJobInstance.getId());
assertThat(firstJobArtifactPlans.size(), is(1));
assertThat(firstJobArtifactPlans.get(0).getId(), equalTo(artifactPlanOfFirstJob.getId()));
assertThat(firstJobArtifactPlans, hasItem(artifactPlanOfFirstJob));
assertThat(artifactPlan.getId(), is(not(nullValue())));
List<ArtifactPlan> secondJobArtifactPlans = artifactPlanRepository.findByBuildId(secondJobInstance.getId());
assertThat(secondJobArtifactPlans.size(), is(1));
assertThat(secondJobArtifactPlans.get(0).getId(), equalTo(artifactPlanOfSecondJob.getId()));
assertThat(secondJobArtifactPlans, hasItem(artifactPlanOfSecondJob));
assertThat(artifactPlan.getId(), is(not(nullValue())));
assertThat(artifactPlanOfFirstJob.getId(), not(equalTo(artifactPlanOfSecondJob.getId())));
}
use of com.thoughtworks.go.config.ArtifactPlan in project gocd by gocd.
the class ArtifactPlanRepositoryIntegrationTest method shouldSaveArtifactPlan.
@Test
public void shouldSaveArtifactPlan() {
// Arrange
JobInstance jobInstance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME));
ArtifactPlan artifactPlan = new ArtifactPlan("src", "dest");
artifactPlan.setBuildId(jobInstance.getId());
// Act
artifactPlanRepository.save(artifactPlan);
// Assert
assertThat(artifactPlan.getId(), is(not(nullValue())));
}
Aggregations