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