Search in sources :

Example 31 with StageIdentifier

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

the class StageStorage method extractStageIdentifier.

private StageIdentifier extractStageIdentifier(Graph graph) {
    String select = "" + "PREFIX cruise: <" + GoOntology.URI + "> " + "SELECT ?pipelineName ?pipelineCounter ?stageName ?stageCounter WHERE {" + "  ?pipeline a cruise:Pipeline ." + "  ?pipeline cruise:pipelineName ?pipelineName ." + "  ?pipeline cruise:pipelineCounter ?pipelineCounter ." + "  ?pipeline cruise:hasStage ?stage ." + "  ?stage cruise:stageName ?stageName ." + "  ?stage cruise:stageCounter ?stageCounter ." + "}";
    BoundVariables bv = graph.selectFirst(select);
    if (bv == null) {
        throw new ShineRuntimeException("Cannot save a stage graph without stage identification information!");
    }
    StageIdentifier stageIdentifier = new StageIdentifier(bv.getString("pipelineName"), bv.getInt("pipelineCounter"), bv.getString("stageName"), bv.getString("stageCounter"));
    return stageIdentifier;
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) BoundVariables(com.thoughtworks.studios.shine.semweb.BoundVariables) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException)

Example 32 with StageIdentifier

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

the class StageFeedEntryTest method shouldNotAddDuplicateMingleCardsToMingleCardsList.

@Test
public void shouldNotAddDuplicateMingleCardsToMingleCardsList() {
    StageFeedEntry entry = new StageFeedEntry(1, 1, new StageIdentifier(), 1, new Date(), StageResult.Passed);
    entry.addCard(new MingleCard(new MingleConfig("mingle-url", "project-name", null), "#1234"));
    entry.addCard(new MingleCard(new MingleConfig("mingle-url", "project-name", null), "#1234"));
    entry.addCard(new MingleCard(new MingleConfig("mingle-url", "project-name-2", null), "#5678"));
    assertThat(entry.getMingleCards().size(), is(2));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) MingleCard(com.thoughtworks.go.server.ui.MingleCard) MingleConfig(com.thoughtworks.go.config.MingleConfig) Date(java.util.Date) Test(org.junit.Test)

Example 33 with StageIdentifier

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

the class StageFeedEntryTest method shouldNotAddDuplicateAuthorsCardsToAuthorsList.

@Test
public void shouldNotAddDuplicateAuthorsCardsToAuthorsList() {
    StageFeedEntry entry = new StageFeedEntry(1, 1, new StageIdentifier(), 1, new Date(), StageResult.Passed);
    entry.addAuthor(new Author("name", "email"));
    entry.addAuthor(new Author("name", "email"));
    entry.addAuthor(new Author("name1", "email1"));
    assertThat(entry.getAuthors().size(), is(2));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Author(com.thoughtworks.go.domain.feed.Author) Date(java.util.Date) Test(org.junit.Test)

Example 34 with StageIdentifier

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

the class PipelineUnlockApiService method isUnlockable.

private boolean isUnlockable(String pipelineName, OperationResult result) {
    if (!goConfigService.isLockable(pipelineName)) {
        String msg = format("No lock exists within the pipeline configuration for %s", pipelineName);
        result.conflict(msg, msg, HealthStateType.general(HealthStateScope.GLOBAL));
        return false;
    }
    StageIdentifier stageIdentifier = pipelineLockService.lockedPipeline(pipelineName);
    if (stageIdentifier == null) {
        String msg = "Lock exists within the pipeline configuration but no pipeline instance is currently in progress";
        result.conflict(msg, msg, HealthStateType.general(HealthStateScope.GLOBAL));
        return false;
    }
    if (currentActivityService.isAnyStageActive(stageIdentifier.pipelineIdentifier())) {
        String message = "Locked pipeline instance is currently running (one of the stages is in progress)";
        result.conflict(message, message, HealthStateType.general(HealthStateScope.GLOBAL));
        return false;
    }
    return true;
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 35 with StageIdentifier

use of com.thoughtworks.go.domain.StageIdentifier 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)

Aggregations

StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)58 Test (org.junit.Test)30 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 Pipeline (com.thoughtworks.go.domain.Pipeline)10 Stage (com.thoughtworks.go.domain.Stage)9 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)6 ArrayList (java.util.ArrayList)6 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)5 PipelineState (com.thoughtworks.go.domain.PipelineState)5 Modification (com.thoughtworks.go.domain.materials.Modification)5 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)5 Username (com.thoughtworks.go.server.domain.Username)4 Date (java.util.Date)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 JobInstance (com.thoughtworks.go.domain.JobInstance)3 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)3 PipelineIdentifier (com.thoughtworks.go.domain.PipelineIdentifier)3 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)3 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3