use of org.jboss.pnc.spi.coordinator.CompletionStatus in project pnc by project-ncl.
the class DefaultBuildExecutionSession method getBuildResult.
private BuildResult getBuildResult() {
EnvironmentDriverResult environmentDriverResult = null;
DebugData debugData = getRunningEnvironment() != null ? getRunningEnvironment().getDebugData() : null;
if (debugData != null && debugData.isDebugEnabled()) {
environmentDriverResult = new EnvironmentDriverResult(CompletionStatus.SUCCESS, "", Optional.of(debugData.getSshCredentials()));
}
CompletionStatus completionStatus = CompletionStatus.SUCCESS;
if (executorException == null) {
if (failedReasonStatus != null) {
switch(failedReasonStatus) {
case BUILD_ENV_SETUP_COMPLETE_WITH_ERROR:
case SYSTEM_ERROR:
completionStatus = CompletionStatus.SYSTEM_ERROR;
break;
case COLLECTING_RESULTS_FROM_REPOSITORY_MANAGER_COMPLETED_WITH_ERROR:
case BUILD_COMPLETED_WITH_ERROR:
completionStatus = CompletionStatus.FAILED;
break;
case CANCELLED:
completionStatus = CompletionStatus.CANCELLED;
break;
case DONE_WITH_ERRORS:
executorException = new ExecutorException("DONE_WITH_ERRORS cannot be set as failed reason.");
break;
}
}
}
ProcessException processException = null;
if (executorException != null) {
processException = new ProcessException(executorException);
completionStatus = CompletionStatus.SYSTEM_ERROR;
}
log.debug("Returning result of task {}.", getId());
return new BuildResult(completionStatus, Optional.ofNullable(processException), "", Optional.ofNullable(buildExecutionConfiguration), Optional.ofNullable(buildDriverResult), Optional.ofNullable(repositoryManagerResult), Optional.ofNullable(environmentDriverResult), Optional.empty());
}
use of org.jboss.pnc.spi.coordinator.CompletionStatus in project pnc by project-ncl.
the class DatastoreAdapterTest method shouldStoreRepositoryManagerError.
@Test
public void shouldStoreRepositoryManagerError() throws DatastoreException {
// given
DatastoreMock datastore = new DatastoreMock();
DatastoreAdapter datastoreAdapter = new DatastoreAdapter(datastore);
BuildStatus buildStatus = BuildStatus.SUCCESS;
CompletionStatus completionStatus = CompletionStatus.FAILED;
// when
storeResult(datastoreAdapter, buildStatus, completionStatus);
// then
List<BuildRecord> buildRecords = datastore.getBuildRecords();
Assert.assertEquals(1, buildRecords.size());
BuildRecord buildRecord = buildRecords.get(0);
Assert.assertEquals(BuildStatus.FAILED, buildRecord.getStatus());
Assert.assertTrue(buildRecord.getBuildLog().contains(BUILD_LOG));
Assert.assertTrue(buildRecord.getBuildLog().contains(REPOSITORY_MANAGER_LOG));
}
use of org.jboss.pnc.spi.coordinator.CompletionStatus in project pnc by project-ncl.
the class BuildResultMapper method toDTO.
public BuildResultRest toDTO(BuildResult buildResult) {
CompletionStatus completionStatus = buildResult.getCompletionStatus();
ProcessException processException = buildResult.getProcessException().orElse(null);
String processLog = buildResult.getProcessLog();
BuildExecutionConfigurationRest buildExecutionConfiguration;
if (buildResult.getBuildExecutionConfiguration().isPresent()) {
BuildExecutionConfiguration bec = buildResult.getBuildExecutionConfiguration().get();
buildExecutionConfiguration = new BuildExecutionConfigurationRest(bec);
} else {
buildExecutionConfiguration = null;
}
BuildDriverResultRest buildDriverResult;
if (buildResult.getBuildDriverResult().isPresent()) {
BuildDriverResult result = buildResult.getBuildDriverResult().get();
buildDriverResult = new BuildDriverResultRest(result);
} else {
buildDriverResult = null;
}
RepositoryManagerResultRest repositoryManagerResult;
if (buildResult.getRepositoryManagerResult().isPresent()) {
RepositoryManagerResult result = buildResult.getRepositoryManagerResult().get();
repositoryManagerResult = repositoryManagerResultMapper.toDTO(result);
} else {
repositoryManagerResult = null;
}
EnvironmentDriverResult environmentDriverResult;
if (buildResult.getEnvironmentDriverResult().isPresent()) {
environmentDriverResult = buildResult.getEnvironmentDriverResult().get();
} else {
environmentDriverResult = null;
}
RepourResult repourResult = buildResult.getRepourResult().orElse(null);
return new BuildResultRest(completionStatus, processException, processLog, buildExecutionConfiguration, buildDriverResult, repositoryManagerResult, environmentDriverResult, repourResult);
}
use of org.jboss.pnc.spi.coordinator.CompletionStatus in project pnc by project-ncl.
the class RepositoryManagerResultMapper method toEntity.
public RepositoryManagerResult toEntity(RepositoryManagerResultRest dto) {
List<org.jboss.pnc.model.Artifact> builtArtifacts = dto.getBuiltArtifacts().stream().map(artifactRest -> artifactMapper.toEntityWithTransientTargetRepository(artifactRest)).collect(Collectors.toList());
List<org.jboss.pnc.model.Artifact> dependencies = dto.getDependencies().stream().map(artifactRest -> artifactMapper.toEntityWithTransientTargetRepository(artifactRest)).collect(Collectors.toList());
String buildContentId = dto.getBuildContentId();
String log = dto.getLog();
CompletionStatus completionStatus = dto.getCompletionStatus();
return new GenericRepositoryManagerResult(builtArtifacts, dependencies, buildContentId, log, completionStatus);
}
use of org.jboss.pnc.spi.coordinator.CompletionStatus in project pnc by project-ncl.
the class IndyRepositorySession method extractBuildArtifacts.
/**
* Retrieve tracking report from repository manager. Add each tracked download to the dependencies of the build
* result. Add each tracked upload to the built artifacts of the build result. Promote uploaded artifacts to the
* product-level storage. Finally delete the group associated with the completed build.
*
* @param liveBuild {@inheritDoc} - if true, the promotion of the collected artifacts and dependencies is done,
* tracking report is sealed and the build group is removed, if false it only reads the data without any
* actions
*/
@Override
public RepositoryManagerResult extractBuildArtifacts(final boolean liveBuild) throws RepositoryManagerException {
TrackedContentDTO report = sealAndGetTrackingReport(liveBuild);
Comparator<Artifact> comp = (one, two) -> one.getIdentifier().compareTo(two.getIdentifier());
Uploads uploads = collectUploads(report);
List<Artifact> uploadedArtifacts = uploads.getData();
Collections.sort(uploadedArtifacts, comp);
List<Artifact> downloadedArtifacts = null;
String log = "";
CompletionStatus status = CompletionStatus.SUCCESS;
try {
downloadedArtifacts = processDownloads(report, liveBuild);
Collections.sort(downloadedArtifacts, comp);
} catch (PromotionValidationException ex) {
status = CompletionStatus.FAILED;
log = ex.getMessage();
logger.warn("Dependencies promotion failed. Error(s): {}", log);
userLog.error("Dependencies promotion failed. Error(s): {}", log);
}
if (liveBuild) {
deleteBuildGroup();
}
// if the promotion of dependencies succeeded...
if (status == CompletionStatus.SUCCESS) {
logger.info("Returning built artifacts / dependencies:\nUploads:\n {}\n\nDownloads:\n {}\n\n", StringUtils.join(uploads.getData(), "\n "), StringUtils.join(downloadedArtifacts, "\n "));
if (liveBuild) {
logger.info("BEGIN: promotion to build content set");
StopWatch stopWatch = StopWatch.createStarted();
try {
promoteToBuildContentSet(uploads.getPromotion());
} catch (PromotionValidationException ex) {
status = CompletionStatus.FAILED;
log = ex.getMessage();
logger.warn("Built artifact promotion failed. Error(s): {}", log);
userLog.error("Built artifact promotion failed. Error(s): {}", log);
}
logger.info("END: promotion to build content set, took: {} seconds", stopWatch.getTime(TimeUnit.SECONDS));
stopWatch.reset();
}
}
if (status == CompletionStatus.FAILED) {
// prevent saving artifacts and dependencies to a failed build
downloadedArtifacts = Collections.emptyList();
uploadedArtifacts = Collections.emptyList();
}
return new IndyRepositoryManagerResult(uploadedArtifacts, downloadedArtifacts, buildContentId, log, status);
}
Aggregations