use of org.jboss.pnc.spi.exception.BuildConflictException in project pnc by project-ncl.
the class ProjectBuilder method buildProject.
BuildTask buildProject(BuildConfiguration buildConfiguration, BuildCoordinator buildCoordinator, Consumer<BuildStatusChangedEvent> onStatusUpdate, BuildOptions buildOptions) throws BuildConflictException, InterruptedException, CoreException {
log.debug("Building project {}", buildConfiguration.getName());
List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
Consumer<BuildStatusChangedEvent> onStatusUpdateInternal = (statusUpdate) -> {
receivedStatuses.add(statusUpdate);
onStatusUpdate.accept(statusUpdate);
};
// Defines a number of callbacks, which are executed after buildStatus update
final Semaphore semaphore = registerReleaseListenersAndAcquireSemaphore(onStatusUpdateInternal, N_STATUS_UPDATES_PER_TASK);
BuildSetTask taskSet = buildCoordinator.build(buildConfiguration, MockUser.newTestUser(1), buildOptions);
Set<BuildTask> buildTasks = taskSet.getBuildTasks();
assertThat(buildTasks).hasSize(1);
BuildTask buildTask = buildTasks.iterator().next();
log.info("Started build task {}", buildTask);
assertBuildStartedSuccessfully(buildTask);
waitForStatusUpdates(N_STATUS_UPDATES_PER_TASK, semaphore, "");
return buildTask;
}
use of org.jboss.pnc.spi.exception.BuildConflictException in project pnc by project-ncl.
the class SkippingBuiltConfigsTest method shouldTriggerTheSameBuildConfigurationWithNewRevision.
@Test
public void shouldTriggerTheSameBuildConfigurationWithNewRevision() throws Exception {
coordinator.start();
buildRecordRepository.clear();
// given
BuildConfiguration testConfiguration = config("shouldRejectBCWithNewRevision");
BuildOptions buildOptions = new BuildOptions();
buildOptions.setBuildDependencies(false);
// when
coordinator.build(testConfiguration, user, buildOptions);
BuildConfiguration updatedConfiguration = updateConfiguration(testConfiguration);
BuildSetTask buildSetTask;
boolean rejected = false;
try {
buildSetTask = coordinator.build(updatedConfiguration, user, buildOptions);
} catch (BuildConflictException e) {
rejected = true;
}
// then
Assert.assertFalse("The task was rejected.", rejected);
waitForEmptyBuildQueue();
assertThat(getNonRejectedBuildRecords().size()).isEqualTo(2);
}
use of org.jboss.pnc.spi.exception.BuildConflictException in project pnc by project-ncl.
the class GroupConfigurationEndpointImpl method triggerBuild.
private GroupBuild triggerBuild(String groupConfigId, Optional<GroupBuildRequest> buildConfigRevisions, GroupBuildParameters buildParams) {
try {
BuildOptions buildOptions = toBuildOptions(buildParams);
int groupBuildId = buildTriggerer.triggerGroupBuild(Integer.parseInt(groupConfigId), buildConfigRevisions, buildOptions);
return groupBuildProvider.getSpecific(Integer.toString(groupBuildId));
} catch (BuildConflictException ex) {
throw new AlreadyRunningException(ex, ex.getBuildTaskId());
} catch (CoreException ex) {
throw new RuntimeException(ex);
}
}
Aggregations