Search in sources :

Example 21 with ArtifactPlan

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"));
}
Also used : ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) File(java.io.File) Test(org.junit.Test)

Example 22 with ArtifactPlan

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;
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) EnvironmentVariableConfig(com.thoughtworks.go.config.EnvironmentVariableConfig) ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) JobPlan(com.thoughtworks.go.domain.JobPlan) Element(org.dom4j.Element) DOMElement(org.dom4j.dom.DOMElement) DOMDocument(org.dom4j.dom.DOMDocument) Resource(com.thoughtworks.go.config.Resource) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) DOMElement(org.dom4j.dom.DOMElement) Document(org.dom4j.Document) DOMDocument(org.dom4j.dom.DOMDocument) Property(com.thoughtworks.go.domain.Property)

Example 23 with ArtifactPlan

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;
}
Also used : ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan)

Example 24 with ArtifactPlan

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())));
}
Also used : ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) Test(org.junit.Test)

Example 25 with ArtifactPlan

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())));
}
Also used : ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) Test(org.junit.Test)

Aggregations

ArtifactPlan (com.thoughtworks.go.config.ArtifactPlan)29 Test (org.junit.Test)25 TestArtifactPlan (com.thoughtworks.go.config.TestArtifactPlan)15 ArtifactPlans (com.thoughtworks.go.config.ArtifactPlans)8 File (java.io.File)7 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 Cloner (com.rits.cloning.Cloner)1 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)1 JobConfig (com.thoughtworks.go.config.JobConfig)1 Resource (com.thoughtworks.go.config.Resource)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 JobPlan (com.thoughtworks.go.domain.JobPlan)1 Property (com.thoughtworks.go.domain.Property)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 DefaultGoPublisher (com.thoughtworks.go.work.DefaultGoPublisher)1 Document (org.dom4j.Document)1 Element (org.dom4j.Element)1 DOMDocument (org.dom4j.dom.DOMDocument)1 DOMElement (org.dom4j.dom.DOMElement)1