Search in sources :

Example 16 with BuildOptions

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);
}
Also used : BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildRecord(org.jboss.pnc.model.BuildRecord) Test(org.junit.Test)

Example 17 with BuildOptions

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());
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildOptions(org.jboss.pnc.spi.BuildOptions) Test(org.junit.Test)

Example 18 with BuildOptions

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);
            }
        }
    }
}
Also used : BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) AlignmentPreference(org.jboss.pnc.api.enums.AlignmentPreference) MDCUtils(org.jboss.pnc.common.logging.MDCUtils) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) Supplier(java.util.function.Supplier) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) HashSet(java.util.HashSet) Map(java.util.Map) ProductMilestone(org.jboss.pnc.model.ProductMilestone) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) User(org.jboss.pnc.model.User) DatastoreAdapter(org.jboss.pnc.coordinator.builder.datastore.DatastoreAdapter) Logger(org.slf4j.Logger) ExpiresDate(org.jboss.pnc.common.Date.ExpiresDate) ContentIdentityManager(org.jboss.pnc.model.utils.ContentIdentityManager) DatastoreException(org.jboss.pnc.spi.datastore.DatastoreException) Set(java.util.Set) Collectors(java.util.stream.Collectors) CoreException(org.jboss.pnc.spi.exception.CoreException) Optional(java.util.Optional) Collections(java.util.Collections) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask)

Example 19 with BuildOptions

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);
    }
}
Also used : CoreException(org.jboss.pnc.spi.exception.CoreException) BuildOptions(org.jboss.pnc.spi.BuildOptions)

Example 20 with BuildOptions

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;
}
Also used : BuildOptions(org.jboss.pnc.spi.BuildOptions)

Aggregations

BuildOptions (org.jboss.pnc.spi.BuildOptions)35 Test (org.junit.Test)21 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)11 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)10 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)9 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)9 BuildRecord (org.jboss.pnc.model.BuildRecord)8 BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)5 BuildSetStatus (org.jboss.pnc.spi.BuildSetStatus)5 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 BuildStatus (org.jboss.pnc.enums.BuildStatus)4 DatastoreMock (org.jboss.pnc.mock.datastore.DatastoreMock)4 TestProjectConfigurationBuilder (org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder)4 BuildCoordinator (org.jboss.pnc.spi.coordinator.BuildCoordinator)4 BuildStatusChangedEvent (org.jboss.pnc.spi.events.BuildStatusChangedEvent)4 BuildConflictException (org.jboss.pnc.spi.exception.BuildConflictException)4 CoreException (org.jboss.pnc.spi.exception.CoreException)4 Collections (java.util.Collections)3 Date (java.util.Date)3 List (java.util.List)3