use of org.jboss.pnc.spi.exception.CoreException in project pnc by project-ncl.
the class BpmBuildScheduler method startBuilding.
@Override
public void startBuilding(BuildTask buildTask) throws CoreException {
try {
Map<String, String> genericParameters = buildTask.getBuildConfigurationAudited().getGenericParameters();
BpmBuildTask task = new BpmBuildTask(buildTask);
if (useNewProcessForBuild(genericParameters, bpmConfig.isNewBpmForced())) {
task.setGlobalConfig(globalConfig);
task.setBpmConfig(bpmConfig);
task.setJsonEncodedProcessParameters(false);
restConnector.startProcess(bpmConfig.getBpmNewBuildProcessName(), task.getExtendedProcessParameters(), buildTask.getId(), task.getAccessToken());
} else {
manager.startTask(task);
}
} catch (Exception e) {
throw new CoreException("Error while trying to startBuilding with BpmBuildScheduler.", e);
}
}
use of org.jboss.pnc.spi.exception.CoreException in project pnc by project-ncl.
the class LocalBuildScheduler method startBuilding.
@Override
public void startBuilding(BuildTask buildTask) throws CoreException {
Consumer<BuildExecutionStatusChangedEvent> onBuildExecutionStatusChangedEvent = (statusChangedEvent) -> {
try {
log.debug("Received execution status update {}.", statusChangedEvent);
if (statusChangedEvent.getNewStatus().isCompleted()) {
BuildResult buildResult = statusChangedEvent.getBuildResult().get();
log.debug("Notifying build execution completed {}.", statusChangedEvent);
buildCoordinator.completeBuild(buildTask, buildResult);
}
} catch (Throwable t) {
log.error("Failed to notify build completion.", t);
}
};
String contentId = ContentIdentityManager.getBuildContentId(buildTask.getId());
BuildConfigurationAudited configuration = buildTask.getBuildConfigurationAudited();
BuildExecutionConfiguration buildExecutionConfiguration = BuildExecutionConfiguration.build(buildTask.getId(), contentId, buildTask.getUser().getId().toString(), configuration.getBuildScript(), configuration.getId().toString(), configuration.getName(), configuration.getRepositoryConfiguration().getInternalUrl(), configuration.getScmRevision(), null, configuration.getRepositoryConfiguration().getExternalUrl(), configuration.getRepositoryConfiguration().isPreBuildSyncEnabled(), configuration.getBuildEnvironment().getSystemImageId(), configuration.getBuildEnvironment().getSystemImageRepositoryUrl(), configuration.getBuildEnvironment().getSystemImageType(), configuration.getBuildType(), buildTask.getBuildOptions().isKeepPodOnFailure(), configuration.getGenericParameters(), buildTask.getBuildOptions().isTemporaryBuild(), TimeUtils.generateTimestamp(buildTask.getBuildOptions().isTimestampAlignment(), buildTask.getBuildSetTask().getStartTime()), configuration.isBrewPullActive(), configuration.getDefaultAlignmentParams(), buildTask.getBuildOptions().getAlignmentPreference());
try {
buildExecutor.startBuilding(buildExecutionConfiguration, onBuildExecutionStatusChangedEvent, buildTask.getUser().getLoginToken());
} catch (ExecutorException e) {
throw new CoreException("Could not start build execution.", e);
}
}
use of org.jboss.pnc.spi.exception.CoreException in project pnc by project-ncl.
the class ProductMilestoneReleaseManager method triggerRHPAMRelease.
/**
* Trigger the release using the new RHPAM server
*
* @param milestone milestone to be released
* @param accessToken access token to use to submit request
* @param milestoneReleaseId the milestone id
*/
private ProductMilestoneRelease triggerRHPAMRelease(ProductMilestone milestone, String accessToken, Long milestoneReleaseId) {
ProductMilestoneRelease release = new ProductMilestoneRelease();
release.setId(milestoneReleaseId);
release.setStartingDate(new Date());
release.setMilestone(milestone);
try (RestConnector restConnector = new RestConnector(bpmConfig)) {
MilestoneReleaseTask releaseTask = new MilestoneReleaseTask(milestone, accessToken);
releaseTask.setTaskId(bpmManager.getNextTaskId());
releaseTask.setGlobalConfig(globalConfig);
releaseTask.setJsonEncodedProcessParameters(false);
restConnector.startProcess(bpmConfig.getBpmNewReleaseProcessId(), releaseTask.getExtendedProcessParameters(), Numbers.decimalToBase32(milestoneReleaseId), accessToken);
return release;
} catch (CoreException | ProcessManagerException e) {
log.error("Error trying to start brew push task for milestone: {}", milestone.getId(), e);
userLog.error("Release process creation failed.", e);
release.setStatus(MilestoneCloseStatus.SYSTEM_ERROR);
release.setEndDate(new Date());
return release;
}
}
use of org.jboss.pnc.spi.exception.CoreException in project pnc by project-ncl.
the class ProductMilestoneReleaseManager method triggerRelease.
@Deprecated
private ProductMilestoneRelease triggerRelease(ProductMilestone milestone, String accessToken, Long milestoneReleaseId) {
ProductMilestoneRelease release = new ProductMilestoneRelease();
release.setId(milestoneReleaseId);
release.setStartingDate(new Date());
release.setMilestone(milestone);
try {
MilestoneReleaseTask releaseTask = new MilestoneReleaseTask(milestone, accessToken);
Integer id = milestone.getId();
releaseTask.<MilestoneReleaseResultRest>addListener(BpmEventType.BREW_IMPORT, r -> onPushResult(id, r));
release.setStatus(MilestoneCloseStatus.IN_PROGRESS);
bpmManager.startTask(releaseTask);
userLog.info("Release process started.");
productMilestoneCloseResultEvent.fire(mapper.toDTO(release));
return release;
} catch (CoreException e) {
log.error("Error trying to start brew push task for milestone: {}", milestone.getId(), e);
userLog.error("Release process creation failed.", e);
release.setStatus(MilestoneCloseStatus.SYSTEM_ERROR);
release.setEndDate(new Date());
productMilestoneCloseResultEvent.fire(mapper.toDTO(release));
return release;
}
}
use of org.jboss.pnc.spi.exception.CoreException in project pnc by project-ncl.
the class BuildConfigurationEndpointImpl method triggerBuild.
private Build triggerBuild(String id, OptionalInt rev, BuildParameters buildParams) throws BuildConflictException {
try {
logger.debug("Endpoint /build requested for buildConfigurationId: {}, revision: {}, parameters: {}", id, rev, buildParams);
BuildOptions buildOptions = toBuildOptions(buildParams);
String buildId = buildTriggerer.triggerBuild(Integer.parseInt(id), rev, buildOptions);
return buildProvider.getSpecific(buildId);
} catch (CoreException ex) {
throw new RuntimeException(ex);
}
}
Aggregations