use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.
the class SkippingBuiltConfigsTest method shouldRerunTheSameBuildConfigurationIfRebuildAllIsSpecified.
@Test
public void shouldRerunTheSameBuildConfigurationIfRebuildAllIsSpecified() throws Exception {
buildRecordRepository.clear();
BuildOptions buildOptions = new BuildOptions();
buildOptions.setRebuildMode(RebuildMode.FORCE);
// when
coordinator.build(configA, user, buildOptions);
waitForEmptyBuildQueue();
coordinator.build(configA, user, buildOptions);
waitForEmptyBuildQueue();
// then
List<BuildRecord> buildRecords = getNonRejectedBuildRecords();
assertThat(buildRecords.size()).isEqualTo(2);
logRecords(buildRecords);
}
use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.
the class SkippingBuiltConfigsTest method shouldNotTriggerTheSameBuildConfigurationViaDependency.
@Test
public void shouldNotTriggerTheSameBuildConfigurationViaDependency() throws Exception {
coordinator.start();
buildRecordRepository.clear();
// given
BuildConfiguration configurationA = config("configurationA");
BuildConfiguration configurationB = config("configurationB");
configurationA.addDependency(configurationB);
BuildOptions buildOptions = new BuildOptions();
// when
coordinator.build(configurationB, user, buildOptions);
Thread.sleep(50);
coordinator.build(configurationA, user, buildOptions);
// then
waitForEmptyBuildQueue();
Assert.assertEquals("There should be 2 build records.", 2, buildRecordRepository.queryAll().size());
}
use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.
the class BuildTasksInitializer method fillBuildTaskSet.
/**
* Creates build tasks and sets up the appropriate dependency relations
*
* @param buildSetTask The build set task which will contain the build tasks. This must already have initialized the
* BuildConfigSet, BuildConfigSetRecord, Milestone, etc.
*/
private void fillBuildTaskSet(BuildSetTask buildSetTask, User user, Supplier<String> buildTaskIdProvider, ProductMilestone productMilestone, Set<BuildConfigurationAudited> toBuild, Set<BuildTask> alreadySubmittedBuildTasks, BuildOptions buildOptions) {
for (BuildConfigurationAudited buildConfigAudited : toBuild) {
Optional<BuildTask> taskOptional = alreadySubmittedBuildTasks.stream().filter(bt -> bt.getBuildConfigurationAudited().equals(buildConfigAudited)).findAny();
BuildTask buildTask;
if (taskOptional.isPresent()) {
buildTask = taskOptional.get();
log.debug("Linking BuildConfigurationAudited {} to existing task {}.", buildConfigAudited, buildTask);
} else {
String buildId = buildTaskIdProvider.get();
String buildContentId = ContentIdentityManager.getBuildContentId(buildId);
// Used only for this operation inside the loop
MDCUtils.addBuildContext(buildContentId, buildOptions.isTemporaryBuild(), ExpiresDate.getTemporaryBuildExpireDate(temporaryBuildLifespanDays, buildOptions.isTemporaryBuild()), user.getId().toString());
try {
Optional<String> requestContext = MDCUtils.getRequestContext();
buildTask = BuildTask.build(buildConfigAudited, buildSetTask.getBuildOptions(), user, buildId, buildSetTask, buildSetTask.getStartTime(), productMilestone, buildContentId, requestContext);
log.debug("Created new buildTask {} for BuildConfigurationAudited {}.", buildTask, buildConfigAudited);
} finally {
MDCUtils.removeBuildContext();
}
}
buildSetTask.addBuildTask(buildTask);
}
// Loop again to set dependencies
for (BuildTask buildTask : buildSetTask.getBuildTasks()) {
for (BuildTask checkDepBuildTask : buildSetTask.getBuildTasks()) {
if (buildTask.hasDirectConfigDependencyOn(checkDepBuildTask)) {
buildTask.addDependency(checkDepBuildTask);
}
}
}
}
use of org.jboss.pnc.spi.BuildOptions 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);
}
}
use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.
the class BuildConfigurationEndpointImpl method toBuildOptions.
private BuildOptions toBuildOptions(BuildParameters buildParams) {
BuildOptions buildOptions = new BuildOptions(buildParams.isTemporaryBuild(), buildParams.isBuildDependencies(), buildParams.isKeepPodOnFailure(), false, buildParams.getRebuildMode(), buildParams.getAlignmentPreference());
checkBuildOptionsValidity(buildOptions);
return buildOptions;
}
Aggregations