use of org.jboss.pnc.spi.builddriver.BuildDriver in project pnc by project-ncl.
the class DefaultBuildExecutor method runTheBuild.
private CompletableFuture<CompletedBuild> runTheBuild(DefaultBuildExecutionSession buildExecutionSession) {
CompletableFuture<CompletedBuild> waitToCompleteFuture = new CompletableFuture<>();
if (buildExecutionSession.isCanceled()) {
waitToCompleteFuture.complete(null);
return waitToCompleteFuture;
}
ProcessStageUtils.logProcessStageBegin(BuildExecutionStatus.BUILD_SETTING_UP.toString(), "Running the build ...");
buildExecutionSession.setStatus(BuildExecutionStatus.BUILD_SETTING_UP);
RunningEnvironment runningEnvironment = buildExecutionSession.getRunningEnvironment();
try {
Consumer<CompletedBuild> onComplete = value -> {
ProcessStageUtils.logProcessStageEnd(BuildExecutionStatus.BUILD_SETTING_UP.toString(), "Build completed.");
waitToCompleteFuture.complete(value);
};
Consumer<Throwable> onError = (e) -> {
ProcessStageUtils.logProcessStageEnd(BuildExecutionStatus.BUILD_SETTING_UP.toString(), "Build failed.");
waitToCompleteFuture.completeExceptionally(new BuildProcessException(e, runningEnvironment));
};
String buildAgentUrl = runningEnvironment.getBuildAgentUrl();
String liveLogWebSocketUrl = "ws" + StringUtils.addEndingSlash(buildAgentUrl).replaceAll("http(s?):", ":") + "socket/text/ro";
log.debug("Setting live log websocket url: {}", liveLogWebSocketUrl);
buildExecutionSession.setLiveLogsUri(Optional.of(new URI(liveLogWebSocketUrl)));
BuildDriver buildDriver = buildDriverFactory.getBuildDriver();
RunningBuild runningBuild = buildDriver.startProjectBuild(buildExecutionSession, runningEnvironment, onComplete, onError);
buildExecutionSession.setCancelHook(runningBuild::cancel);
buildExecutionSession.setStatus(BuildExecutionStatus.BUILD_WAITING);
} catch (Throwable e) {
throw new BuildProcessException(e, runningEnvironment);
}
return waitToCompleteFuture;
}
use of org.jboss.pnc.spi.builddriver.BuildDriver in project pnc by project-ncl.
the class BuildDriverFactoryTest method shouldSkipDriversWhichAreNotMentionedInConfiguration.
@Test(expected = ExecutorException.class)
public void shouldSkipDriversWhichAreNotMentionedInConfiguration() throws Exception {
// given
ProperDriver testedBuildDriver = new ProperDriver();
TestInstance<BuildDriver> allDrivers = new TestInstance<>(testedBuildDriver);
Configuration configuration = new Configuration();
BuildDriverFactory factory = new BuildDriverFactory(allDrivers, configuration);
factory.initConfiguration();
// when
factory.getBuildDriver();
}
use of org.jboss.pnc.spi.builddriver.BuildDriver in project pnc by project-ncl.
the class BuildDriverFactoryTest method shouldPickProperDriver.
@Test
public void shouldPickProperDriver() throws Exception {
// given
ProperDriver testedBuildDriver = new ProperDriver();
TestInstance<BuildDriver> allDrivers = new TestInstance<>(testedBuildDriver);
Configuration configuration = mock(Configuration.class);
BuildDriverFactory factory = new BuildDriverFactory(allDrivers, configuration);
// when
BuildDriver buildDriver = factory.getBuildDriver();
// then
assertThat(buildDriver).isEqualTo(testedBuildDriver);
}
Aggregations