Search in sources :

Example 41 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class EnvironmentVariableContextTest method shouldPopulateEnvironmentForMaterialUsingDest.

@Test
public void shouldPopulateEnvironmentForMaterialUsingDest() throws IOException {
    SvnMaterial svn = MaterialsMother.svnMaterial();
    svn.setFolder("svn-dir");
    MaterialRevision revision = new MaterialRevision(svn, ModificationsMother.oneModifiedFile("revision1"));
    MaterialRevisions materialRevisions = new MaterialRevisions(revision);
    EnvironmentVariableContext context = new EnvironmentVariableContext();
    context.setProperty("GO_SERVER_URL", SystemEnvironment.getProperty("serviceUrl"), false);
    jobIdentifier().populateEnvironmentVariables(context);
    materialRevisions.populateEnvironmentVariables(context, temporaryFolder.newFolder());
    assertThat(context.getProperty("GO_REVISION_SVN_DIR"), is("revision1"));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.Test)

Example 42 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class StageNotificationService method sendNotifications.

public void sendNotifications(StageIdentifier stageIdentifier, StageEvent event, Username cancelledBy) {
    Users users = userService.findValidSubscribers(stageIdentifier.stageConfigIdentifier());
    if (users.isEmpty()) {
        return;
    }
    Stage stage = stageService.findStageWithIdentifier(stageIdentifier);
    Pipeline pipeline = pipelineService.fullPipelineById(stage.getPipelineId());
    MaterialRevisions materialRevisions = pipeline.getMaterialRevisions();
    List<TestSuite> failedTestSuites = null;
    if (systemEnvironment.isShineEnabled()) {
        failedTestSuites = shineDao.failedTestsFor(stageIdentifier);
    }
    String emailBody = new EmailBodyGenerator(materialRevisions, cancelledBy, systemEnvironment, stageIdentifier, failedTestSuites).getContent();
    String subject = "Stage [" + stageIdentifier.stageLocator() + "]" + event.describe();
    LOGGER.debug("Processing notification titled [{}]", subject);
    for (User user : users) {
        if (user.matchNotification(stageIdentifier.stageConfigIdentifier(), event, materialRevisions)) {
            StringBuilder emailWithSignature = new StringBuilder(emailBody).append("\n\n").append("Sent by Go on behalf of ").append(user.getName());
            SendEmailMessage sendEmailMessage = new SendEmailMessage(subject, emailWithSignature.toString(), user.getEmail());
            emailNotificationTopic.post(sendEmailMessage);
        }
    }
    LOGGER.debug("Finished processing notification titled [{}]", subject);
}
Also used : User(com.thoughtworks.go.domain.User) SendEmailMessage(com.thoughtworks.go.server.messaging.SendEmailMessage) TestSuite(com.thoughtworks.go.domain.testinfo.TestSuite) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Stage(com.thoughtworks.go.domain.Stage) Users(com.thoughtworks.go.domain.Users) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline)

Example 43 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class FanInGraph method createFinalRevisionsForScmChildren.

private List<MaterialRevision> createFinalRevisionsForScmChildren(PipelineTimelineEntry latestRootNodeInstance, List<RootFanInNode> scmChildren, List<DependencyFanInNode> depChildren) {
    Set<FaninScmMaterial> scmMaterialsFromDepChildren = scmMaterialsOfDepChildren(depChildren);
    List<MaterialRevision> finalRevisions = new ArrayList<>();
    for (RootFanInNode child : scmChildren) {
        child.setScmRevision(scmMaterialsFromDepChildren);
        MaterialConfig materialConfig = child.materialConfig;
        Material material = materialConfigConverter.toMaterial(materialConfig);
        MaterialRevision revision = new MaterialRevision(material);
        if (latestRootNodeInstance != null) {
            PipelineInstanceModel pipeline = pipelineDao.findPipelineHistoryByNameAndCounter(latestRootNodeInstance.getPipelineName(), latestRootNodeInstance.getCounter());
            for (MaterialRevision materialRevision : pipeline.getCurrentRevisions()) {
                if (materialRevision.getMaterial().getFingerprint().equals(child.materialConfig.getFingerprint())) {
                    List<Modification> modificationsSince = materialRepository.findModificationsSinceAndUptil(material, materialRevision, child.scmRevision);
                    revision.addModifications(modificationsSince);
                    break;
                }
            }
        }
        if (revision.getModifications().isEmpty() && child.scmRevision == null) {
            MaterialRevisions latestRevisions = materialRepository.findLatestRevisions(new MaterialConfigs(materialConfig));
            finalRevisions.addAll(latestRevisions.getRevisions());
            continue;
        }
        if (revision.getModifications().isEmpty()) {
            revision = new MaterialRevision(material, materialRepository.findModificationWithRevision(material, child.scmRevision.revision));
        }
        finalRevisions.add(revision);
    }
    return finalRevisions;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Material(com.thoughtworks.go.domain.materials.Material) PipelineInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 44 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class CcTrayBreakersCalculatorTest method shouldCaptureUniqueModificationAuthorNamesAsBreakers_inCaseOfFailure.

@Test
public void shouldCaptureUniqueModificationAuthorNamesAsBreakers_inCaseOfFailure() throws Exception {
    Modification user1Commit = ModificationsMother.checkinWithComment("123", "comment 1", "user1", "user1@domain1.com", new Date(), "foo.c");
    Modification user2Commit = ModificationsMother.checkinWithComment("124", "comment 2", "user2", "user2@domain2.com", new Date(), "bar.c");
    Modification otherCommitOfUser1 = ModificationsMother.checkinWithComment("125", "comment 3", "user1", "user1@different-email.com", new Date(), "baz.c");
    MaterialRevision revision = new MaterialRevision(MaterialsMother.gitMaterial("foo.com"), user1Commit, user2Commit, otherCommitOfUser1);
    revision.markAsChanged();
    when(materialRepo.findMaterialRevisionsForPipeline(12l)).thenReturn(new MaterialRevisions(revision));
    CcTrayBreakersCalculator status = new CcTrayBreakersCalculator(materialRepo);
    Set<String> actualBreakers = status.calculateFor(failedStage());
    assertThat(actualBreakers, is(s("user1", "user2")));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 45 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class CcTrayBreakersCalculatorTest method shouldCaptureAuthorNamesOfChangedRevisionsOnlyAsBreakers.

@Test
public void shouldCaptureAuthorNamesOfChangedRevisionsOnlyAsBreakers() throws Exception {
    Modification user1Commit = ModificationsMother.checkinWithComment("123", "comment 1", "user1", "user1@domain1.com", new Date(), "foo.c");
    Modification user2Commit = ModificationsMother.checkinWithComment("124", "comment 2", "user2", "user2@domain2.com", new Date(), "bar.c");
    MaterialRevision changedRevision = new MaterialRevision(MaterialsMother.gitMaterial("foo.com"), user1Commit, user2Commit);
    changedRevision.markAsChanged();
    Modification user3CommitForUnchangedRevision = ModificationsMother.checkinWithComment("125", "comment 1", "user3", "user3@domain2.com", new Date(), "bar.c");
    MaterialRevision unchangedRevision = new MaterialRevision(MaterialsMother.gitMaterial("bar.com"), user3CommitForUnchangedRevision);
    MaterialRevisions revisions = new MaterialRevisions(changedRevision, unchangedRevision);
    when(materialRepo.findMaterialRevisionsForPipeline(12l)).thenReturn(revisions);
    CcTrayBreakersCalculator status = new CcTrayBreakersCalculator(materialRepo);
    Set<String> actualBreakers = status.calculateFor(failedStage());
    assertThat(actualBreakers, is(s("user1", "user2")));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Aggregations

MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)212 Test (org.junit.Test)166 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)111 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)68 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)55 Date (java.util.Date)49 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)46 Modification (com.thoughtworks.go.domain.materials.Modification)38 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)33 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)31 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)31 Materials (com.thoughtworks.go.config.materials.Materials)27 Pipeline (com.thoughtworks.go.domain.Pipeline)20 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 Material (com.thoughtworks.go.domain.materials.Material)16 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)15 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)14 File (java.io.File)12