Search in sources :

Example 26 with BuildSetTask

use of org.jboss.pnc.spi.coordinator.BuildSetTask in project pnc by project-ncl.

the class DefaultBuildCoordinatorTest method shouldUpdateBuildRecordSetIfBuildSetBuilIsRejected.

@Test
public void shouldUpdateBuildRecordSetIfBuildSetBuilIsRejected() throws DatastoreException, CoreException {
    BuildConfigurationSet bcSet = BuildConfigurationSet.Builder.newBuilder().buildConfigurations(Collections.emptySet()).name("BCSet").id(1).build();
    BuildSetTask bsTask = coordinator.build(bcSet, USER, BUILD_OPTIONS);
    assertThat(bsTask.getBuildConfigSetRecord().get().getStatus()).isEqualTo(BuildStatus.NO_REBUILD_REQUIRED);
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) Test(org.junit.Test)

Example 27 with BuildSetTask

use of org.jboss.pnc.spi.coordinator.BuildSetTask in project pnc by project-ncl.

the class BuildTriggererImpl method triggerBuild.

@Override
public String triggerBuild(final int buildConfigId, OptionalInt buildConfigurationRevision, BuildOptions buildOptions) throws BuildConflictException, CoreException {
    throwCoreExceptionIfInMaintenanceModeAndNonSystemUser();
    BuildSetTask result = doTriggerBuild(buildConfigId, buildConfigurationRevision, buildOptions);
    return selectBuildRecordIdOf(result.getBuildTasks(), buildConfigId);
}
Also used : BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask)

Example 28 with BuildSetTask

use of org.jboss.pnc.spi.coordinator.BuildSetTask in project pnc by project-ncl.

the class BuildTriggererImpl method doTriggerBuild.

private BuildSetTask doTriggerBuild(final int buildConfigId, OptionalInt buildConfigurationRevision, BuildOptions buildOptions) throws BuildConflictException, CoreException {
    BuildSetTask buildSetTask;
    if (buildConfigurationRevision.isPresent()) {
        final BuildConfigurationAudited buildConfigurationAudited = buildConfigurationAuditedRepository.queryById(new IdRev(buildConfigId, buildConfigurationRevision.getAsInt()));
        Preconditions.checkArgument(buildConfigurationAudited != null, "Can't find Build Configuration with id=" + buildConfigId + ", rev=" + buildConfigurationRevision.getAsInt());
        buildSetTask = buildCoordinator.build(hibernateLazyInitializer.initializeBuildConfigurationAuditedBeforeTriggeringIt(buildConfigurationAudited), user.currentUser(), buildOptions);
    } else {
        final BuildConfiguration buildConfiguration = buildConfigurationRepository.queryById(buildConfigId);
        Preconditions.checkArgument(buildConfiguration != null, "Can't find Build Configuration with id=" + buildConfigId);
        buildSetTask = buildCoordinator.build(hibernateLazyInitializer.initializeBuildConfigurationBeforeTriggeringIt(buildConfiguration), user.currentUser(), buildOptions);
    }
    logger.info("Started build of Build Configuration {}. Build Tasks: {}", buildConfigId, buildSetTask.getBuildTasks().stream().map(BuildTask::getId).collect(Collectors.joining()));
    return buildSetTask;
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) IdRev(org.jboss.pnc.model.IdRev)

Example 29 with BuildSetTask

use of org.jboss.pnc.spi.coordinator.BuildSetTask in project pnc by project-ncl.

the class BuildTriggererImpl method triggerGroupBuild.

@Override
public int triggerGroupBuild(int groupConfigId, Optional<GroupBuildRequest> revs, BuildOptions buildOptions) throws BuildConflictException, CoreException {
    throwCoreExceptionIfInMaintenanceModeAndNonSystemUser();
    BuildSetTask result = doTriggerGroupBuild(groupConfigId, revs, buildOptions);
    return result.getId();
}
Also used : BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask)

Example 30 with BuildSetTask

use of org.jboss.pnc.spi.coordinator.BuildSetTask in project pnc by project-ncl.

the class BuildTriggererImpl method doTriggerGroupBuild.

private BuildSetTask doTriggerGroupBuild(final int groupConfigId, Optional<GroupBuildRequest> revs, BuildOptions buildOptions) throws CoreException {
    final BuildConfigurationSet buildConfigurationSet = buildConfigurationSetRepository.queryById(groupConfigId);
    Preconditions.checkArgument(buildConfigurationSet != null, "Can't find configuration with given id=" + groupConfigId);
    List<BuildConfigurationRevisionRef> revisions = revs.map(GroupBuildRequest::getBuildConfigurationRevisions).orElse(Collections.emptyList());
    BuildSetTask buildSetTask = buildCoordinator.build(hibernateLazyInitializer.initializeBuildConfigurationSetBeforeTriggeringIt(buildConfigurationSet), loadAuditedsFromDB(buildConfigurationSet, revisions), user.currentUser(), buildOptions);
    logger.info("Started build of Group Configuration {}. Build Tasks: {}", groupConfigId, buildSetTask.getBuildTasks().stream().map(BuildTask::getId).collect(Collectors.joining()));
    return buildSetTask;
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildConfigurationRevisionRef(org.jboss.pnc.dto.BuildConfigurationRevisionRef)

Aggregations

BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)30 Test (org.junit.Test)15 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)12 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)12 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)11 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)10 BuildOptions (org.jboss.pnc.spi.BuildOptions)10 HashSet (java.util.HashSet)6 BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)6 User (org.jboss.pnc.model.User)6 BuildSetStatus (org.jboss.pnc.spi.BuildSetStatus)6 CoreException (org.jboss.pnc.spi.exception.CoreException)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 List (java.util.List)5 Set (java.util.Set)5 BuildStatus (org.jboss.pnc.enums.BuildStatus)5 BuildCoordinator (org.jboss.pnc.spi.coordinator.BuildCoordinator)5 BuildStatusChangedEvent (org.jboss.pnc.spi.events.BuildStatusChangedEvent)5 Collections (java.util.Collections)4