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