Search in sources :

Example 41 with StageIdentifier

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

the class ArtifactsService method purgeArtifactsForStage.

public void purgeArtifactsForStage(Stage stage) {
    StageIdentifier stageIdentifier = stage.getIdentifier();
    try {
        File stageRoot = chooser.findArtifact(stageIdentifier, "");
        File cachedStageRoot = chooser.findCachedArtifact(stageIdentifier);
        deleteFile(cachedStageRoot);
        boolean didDelete = deleteArtifactsExceptCruiseOutputAndPluggableArtifactMetadata(stageRoot);
        if (!didDelete) {
            LOGGER.error("Artifacts for stage '{}' at path '{}' was not deleted", stageIdentifier.entityLocator(), stageRoot.getAbsolutePath());
        }
    } catch (Exception e) {
        LOGGER.error("Error occurred while clearing artifacts for '{}'. Error: '{}'", stageIdentifier.entityLocator(), e.getMessage(), e);
    }
    stageDao.markArtifactsDeletedFor(stage);
    LOGGER.debug("Marked stage '{}' as artifacts deleted.", stageIdentifier.entityLocator());
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) File(java.io.File) IOException(java.io.IOException) IllegalArtifactLocationException(com.thoughtworks.go.domain.exception.IllegalArtifactLocationException)

Example 42 with StageIdentifier

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

the class CachedCurrentActivityService method stageModel.

private StageJsonPresentationModel stageModel(Pipeline currentPipeline, Stage stage) {
    StageIdentifier lastSuccessfulPipelineForStage = pipelineService.findLastSuccessfulStageIdentifier(currentPipeline.getName(), stage.getName());
    final DurationBeans durations = stageService.getBuildDurations(currentPipeline.getName(), stage);
    TrackingTool trackingTool = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(currentPipeline.getName())).trackingTool();
    return new StageJsonPresentationModel(currentPipeline, stage, lastSuccessfulPipelineForStage, agentService, durations, trackingTool);
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) StageJsonPresentationModel(com.thoughtworks.go.server.presentation.models.StageJsonPresentationModel) DurationBeans(com.thoughtworks.go.dto.DurationBeans) TrackingTool(com.thoughtworks.go.config.TrackingTool) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 43 with StageIdentifier

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

the class DependencyFanInNode method alterRevision.

private RevisionAlteration alterRevision(StageIdFaninScmMaterialPair revisionToSet, FanInGraphContext context) {
    if (currentRevision == revisionToSet.stageIdentifier) {
        return RevisionAlteration.SAME_AS_CURRENT_REVISION;
    }
    if (!stageIdentifierScmMaterial.get(currentRevision).contains(revisionToSet.faninScmMaterial)) {
        return RevisionAlteration.NOT_APPLICABLE;
    }
    List<StageIdentifier> stageIdentifiers = new ArrayList<>(stageIdentifierScmMaterial.keySet());
    int currentRevIndex = stageIdentifiers.indexOf(currentRevision);
    for (int i = currentRevIndex; i < stageIdentifiers.size(); i++) {
        final StageIdentifier key = stageIdentifiers.get(i);
        final List<FaninScmMaterial> materials = new ArrayList<>(stageIdentifierScmMaterial.get(key));
        final int index = materials.indexOf(revisionToSet.faninScmMaterial);
        if (index == -1) {
            return ALL_OPTIONS_EXHAUSTED;
        }
        final FaninScmMaterial faninScmMaterial = materials.get(index);
        if (faninScmMaterial.revision.equals(revisionToSet.faninScmMaterial.revision)) {
            currentRevision = key;
            return ALTERED_TO_CORRECT_REVISION;
        }
        if (faninScmMaterial.revision.lessThan(revisionToSet.faninScmMaterial.revision)) {
            currentRevision = key;
            return ALTERED_TO_CORRECT_REVISION;
        }
    }
    if (!hasMoreInstances()) {
        return ALL_OPTIONS_EXHAUSTED;
    }
    return NEED_MORE_REVISIONS;
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier)

Example 44 with StageIdentifier

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

the class DependencyFanInNode method getRevisionNthFor.

private Pair<StageIdentifier, List<FaninScmMaterial>> getRevisionNthFor(int n, FanInGraphContext context) {
    List<FaninScmMaterial> scmMaterials = new ArrayList<>();
    PipelineTimeline pipelineTimeline = context.pipelineTimeline;
    Queue<PipelineTimelineEntry.Revision> revisionQueue = new ConcurrentLinkedQueue<>();
    DependencyMaterialConfig dependencyMaterial = (DependencyMaterialConfig) materialConfig;
    PipelineTimelineEntry entry = pipelineTimeline.instanceFor(dependencyMaterial.getPipelineName(), totalInstanceCount - n);
    Set<CaseInsensitiveString> visitedNodes = new HashSet<>();
    StageIdentifier dependentStageIdentifier = dependentStageIdentifier(context, entry, CaseInsensitiveString.str(dependencyMaterial.getStageName()));
    if (!StageIdentifier.NULL.equals(dependentStageIdentifier)) {
        addToRevisionQueue(entry, revisionQueue, scmMaterials, context, visitedNodes);
    } else {
        return null;
    }
    while (!revisionQueue.isEmpty()) {
        PipelineTimelineEntry.Revision revision = revisionQueue.poll();
        DependencyMaterialRevision dmr = DependencyMaterialRevision.create(revision.revision, null);
        PipelineTimelineEntry pte = pipelineTimeline.getEntryFor(new CaseInsensitiveString(dmr.getPipelineName()), dmr.getPipelineCounter());
        addToRevisionQueue(pte, revisionQueue, scmMaterials, context, visitedNodes);
    }
    return new Pair<>(dependentStageIdentifier, scmMaterials);
}
Also used : DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Pair(com.thoughtworks.go.util.Pair)

Example 45 with StageIdentifier

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

the class ReportingDependencyFanInNode method getRevisionNthFor.

private Pair<StageIdentifier, List<ReportingFaninScmMaterial>> getRevisionNthFor(int n, ReportingFanInGraphContext context) {
    List<ReportingFaninScmMaterial> scmMaterials = new ArrayList<>();
    PipelineTimeline pipelineTimeline = context.pipelineTimeline;
    Queue<PipelineTimelineEntry.Revision> revisionQueue = new ConcurrentLinkedQueue<>();
    DependencyMaterialConfig dependencyMaterial = (DependencyMaterialConfig) materialConfig;
    PipelineTimelineEntry entry = pipelineTimeline.instanceFor(dependencyMaterial.getPipelineName(), totalInstanceCount - n);
    StageIdentifier dependentStageIdentifier = dependentStageIdentifier(context, entry, CaseInsensitiveString.str(dependencyMaterial.getStageName()));
    if (!StageIdentifier.NULL.equals(dependentStageIdentifier)) {
        addToRevisionQueue(entry, revisionQueue, scmMaterials, context);
    } else {
        return null;
    }
    while (!revisionQueue.isEmpty()) {
        PipelineTimelineEntry.Revision revision = revisionQueue.poll();
        DependencyMaterialRevision dmr = DependencyMaterialRevision.create(revision.revision, null);
        PipelineTimelineEntry pte = pipelineTimeline.getEntryFor(new CaseInsensitiveString(dmr.getPipelineName()), dmr.getPipelineCounter());
        addToRevisionQueue(pte, revisionQueue, scmMaterials, context);
    }
    return new Pair<>(dependentStageIdentifier, scmMaterials);
}
Also used : ArrayList(java.util.ArrayList) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Pair(com.thoughtworks.go.util.Pair)

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