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"));
}
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);
}
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;
}
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")));
}
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")));
}
Aggregations