Search in sources :

Example 51 with Pipeline

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

the class BackgroundStageLoaderIntegrationTest method handleAStageURLNotYetSeenShouldStoreStageResourceIntoStageStorage.

@Test
public void handleAStageURLNotYetSeenShouldStoreStageResourceIntoStageStorage() {
    TestFailureSetup.SavedStage savedStage = failureSetup.setupPipelineInstanceWithoutTestXmlStubbing(true, null, new Date());
    loader.handle(feedEntry(savedStage), pipelineInstanceLoader);
    assertTrue(stageStorage.isStageStored(savedStage.stageId));
    Graph storedGraph = stageStorage.load(savedStage.stageId);
    Stage stage = savedStage.stage;
    String baseUrl = "https://localhost:8154/go";
    String jobUrl = new JobXmlViewModel(stage.getJobInstances().first()).httpUrl(baseUrl);
    assertTrue(storedGraph.containsResourceWithURI(jobUrl));
    assertTrue(storedGraph.containsResourceWithURI(new StageXmlViewModel(stage).httpUrl(baseUrl)));
    Pipeline pipeline = savedStage.pipeline;
    assertTrue(storedGraph.containsResourceWithURI(PipelineXmlViewModel.httpUrlForPipeline(baseUrl, pipeline.getId(), pipeline.getName())));
    Modification latestModification = pipeline.getMaterialRevisions().getRevisions().get(0).getLatestModification();
    assertTrue(storedGraph.containsResourceWithURI(ScmMaterial.changesetUrl(latestModification, baseUrl, latestModification.getMaterialInstance().getId())));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Graph(com.thoughtworks.studios.shine.semweb.Graph) StageXmlViewModel(com.thoughtworks.go.server.domain.xml.StageXmlViewModel) JobXmlViewModel(com.thoughtworks.go.server.domain.xml.JobXmlViewModel) TestFailureSetup(com.thoughtworks.go.server.dao.sparql.TestFailureSetup) Stage(com.thoughtworks.go.domain.Stage) Date(java.util.Date) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 52 with Pipeline

use of com.thoughtworks.go.domain.Pipeline 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 53 with Pipeline

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

the class RestfulService method findJob.

/**
 * buildId should only be given when caller is absolutely sure about the job instance
 * (makes sense in agent-uploading artifacts/properties scenario because agent won't run a job if its copied over(it only executes real jobs)) -JJ
 */
public JobIdentifier findJob(String pipelineName, String counterOrLabel, String stageName, String stageCounter, String buildName, Long buildId) {
    JobConfigIdentifier jobConfig = goConfigService.translateToActualCase(new JobConfigIdentifier(pipelineName, stageName, buildName));
    Pipeline pipeline = pipelineService.findPipelineByCounterOrLabel(jobConfig.getPipelineName(), counterOrLabel);
    stageCounter = StringUtils.isEmpty(stageCounter) ? JobIdentifier.LATEST : stageCounter;
    StageIdentifier stageIdentifier = translateStageCounter(pipeline.getIdentifier(), jobConfig.getStageName(), stageCounter);
    JobIdentifier jobId;
    if (buildId == null) {
        jobId = jobResolverService.actualJobIdentifier(new JobIdentifier(stageIdentifier, jobConfig.getJobName()));
    } else {
        jobId = new JobIdentifier(stageIdentifier, jobConfig.getJobName(), buildId);
    }
    if (jobId == null) {
        // fix for #5739
        throw new JobNotFoundException(pipelineName, stageName, buildName);
    }
    return jobId;
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) JobNotFoundException(com.thoughtworks.go.config.JobNotFoundException) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) JobConfigIdentifier(com.thoughtworks.go.domain.JobConfigIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline)

Example 54 with Pipeline

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

the class BuildCauseProducerServiceWithFlipModificationTest method consume.

private void consume(final BuildCause buildCause) throws SQLException {
    dbHelper.saveRevs(buildCause.getMaterialRevisions());
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            Pipeline latestPipeline = pipelineScheduleQueue.createPipeline(buildCause, mingleConfig, new DefaultSchedulingContext(buildCause.getApprover(), new Agents()), "md5", new TimeProvider());
            // Pipeline latestPipeline = PipelineMother.schedule(mingleConfig, buildCause);
            pipelineDao.saveWithStages(latestPipeline);
            dbHelper.passStage(latestPipeline.getStages().first());
        }
    });
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) Agents(com.thoughtworks.go.config.Agents) TransactionStatus(org.springframework.transaction.TransactionStatus) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) Pipeline(com.thoughtworks.go.domain.Pipeline) DefaultSchedulingContext(com.thoughtworks.go.domain.DefaultSchedulingContext)

Example 55 with Pipeline

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

the class CachedCurrentActivityServiceIntegrationTest method testShouldReturnFalseIfAStageOfAPipelineHasNotStarted.

@Test
public void testShouldReturnFalseIfAStageOfAPipelineHasNotStarted() {
    Pipeline pipeline = fixture.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
    assertThat(cachedCurrentActivityService.isAnyStageActive(pipeline.getIdentifier()), is(false));
}
Also used : Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

Pipeline (com.thoughtworks.go.domain.Pipeline)184 Test (org.junit.Test)122 Stage (com.thoughtworks.go.domain.Stage)33 Username (com.thoughtworks.go.server.domain.Username)30 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)29 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)24 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)24 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)21 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)20 JobInstance (com.thoughtworks.go.domain.JobInstance)19 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)13 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)13 Modification (com.thoughtworks.go.domain.materials.Modification)13 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)13 Date (java.util.Date)13 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)11 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)10 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)8 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)7 PipelineState (com.thoughtworks.go.domain.PipelineState)6