Search in sources :

Example 31 with BuildConfigurationAudited

use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.

the class BuildTasksInitializer method createBuildSetTask.

/**
 * Create a BuildSetTask of BuildConfigurations contained in the BuildConfigurationSet.
 *
 * A specific revision of the BuildConfigurations contained in the set is used, if it's available in the
 * buildConfigurationAuditedsMap parameter. If it's not available, latest revision of the BuildConfiguration is
 * used.
 *
 * @param buildConfigurationSet BuildConfigurationSet to be built
 * @param buildConfigurationAuditedsMap A map BuildConfiguration::id:BuildConfigurationAudited of specific revisions
 *        of BuildConfigurations contained in the buildConfigurationSet
 * @param user A user, who triggered the build
 * @param buildOptions Build options
 * @param buildTaskIdProvider Provider to get build task ID
 * @param submittedBuildTasks Already submitted build tasks
 * @return Prepared BuildSetTask
 * @throws CoreException Thrown if the BuildConfigSetRecord cannot be stored
 */
public BuildSetTask createBuildSetTask(BuildConfigurationSet buildConfigurationSet, Map<Integer, BuildConfigurationAudited> buildConfigurationAuditedsMap, User user, BuildOptions buildOptions, Supplier<String> buildTaskIdProvider, Set<BuildTask> submittedBuildTasks) throws CoreException {
    BuildSetTask buildSetTask = initBuildSetTask(buildConfigurationSet, user, buildOptions);
    Set<BuildConfigurationAudited> buildConfigurationAuditeds = new HashSet<>();
    for (BuildConfiguration buildConfiguration : datastoreAdapter.getBuildConfigurations(buildConfigurationSet)) {
        BuildConfigurationAudited buildConfigurationAudited = buildConfigurationAuditedsMap.get(buildConfiguration.getId());
        if (buildConfigurationAudited == null) {
            buildConfigurationAudited = datastoreAdapter.getLatestBuildConfigurationAuditedInitializeBCDependencies(buildConfiguration.getId());
        }
        buildConfigurationAuditeds.add(buildConfigurationAudited);
    }
    // initializeBuildTasksInSet
    log.debug("Initializing BuildTasks In Set for BuildConfigurationAuditeds: {}.", buildConfigurationAuditeds.stream().map(BuildConfigurationAudited::toString).collect(Collectors.joining("; ")));
    fillBuildTaskSet(buildSetTask, user, buildTaskIdProvider, buildConfigurationSet.getCurrentProductMilestone(), buildConfigurationAuditeds, submittedBuildTasks, buildOptions);
    return buildSetTask;
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) HashSet(java.util.HashSet)

Example 32 with BuildConfigurationAudited

use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.

the class DefaultBuildCoordinator method checkIfAnyBuildConfigurationNeedsARebuild.

private void checkIfAnyBuildConfigurationNeedsARebuild(BuildSetTask buildSetTask, BuildConfigurationSet buildConfigurationSet, boolean checkImplicitDependencies, boolean temporaryBuild, AlignmentPreference alignmentPreference) {
    Set<BuildConfiguration> buildConfigurations = buildConfigurationSet.getBuildConfigurations();
    int requiresRebuild = buildConfigurations.size();
    log.debug("There are {} configurations in a set {}.", requiresRebuild, buildConfigurationSet.getId());
    Set<Integer> processedDependenciesCache = new HashSet<>();
    for (BuildConfiguration buildConfiguration : buildConfigurations) {
        BuildConfigurationAudited buildConfigurationAudited = datastoreAdapter.getLatestBuildConfigurationAuditedInitializeBCDependencies(buildConfiguration.getId());
        if (!datastoreAdapter.requiresRebuild(buildConfigurationAudited, checkImplicitDependencies, temporaryBuild, alignmentPreference, processedDependenciesCache)) {
            requiresRebuild--;
        }
    }
    if (requiresRebuild == 0) {
        updateBuildSetTaskStatus(buildSetTask, BuildSetStatus.NO_REBUILD_REQUIRED, "All build configs were previously built");
    }
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) HashSet(java.util.HashSet)

Example 33 with BuildConfigurationAudited

use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.

the class BpmBuildTask method getBuildExecutionConfiguration.

private BuildExecutionConfigurationRest getBuildExecutionConfiguration(BuildTask buildTask) {
    BuildConfigurationAudited buildConfigurationAudited = buildTask.getBuildConfigurationAudited();
    String contentId = ContentIdentityManager.getBuildContentId(buildTask.getId());
    BuildExecutionConfiguration buildExecutionConfiguration = BuildExecutionConfiguration.build(buildTask.getId(), contentId, buildTask.getUser().getId().toString(), buildConfigurationAudited.getBuildScript(), buildConfigurationAudited.getId().toString(), buildConfigurationAudited.getName(), // TODO update to use also other parts or Repository Configuration
    buildConfigurationAudited.getRepositoryConfiguration().getInternalUrl(), buildConfigurationAudited.getScmRevision(), // SCM Tag is about to be set once it is created after the alignment phase
    null, buildConfigurationAudited.getRepositoryConfiguration().getExternalUrl(), buildConfigurationAudited.getRepositoryConfiguration().isPreBuildSyncEnabled(), buildConfigurationAudited.getBuildEnvironment().getSystemImageId(), buildConfigurationAudited.getBuildEnvironment().getSystemImageRepositoryUrl(), buildConfigurationAudited.getBuildEnvironment().getSystemImageType(), buildConfigurationAudited.getBuildConfiguration().getBuildType(), buildTask.getBuildOptions().isKeepPodOnFailure(), buildConfigurationAudited.getGenericParameters(), buildTask.getBuildOptions().isTemporaryBuild(), TimeUtils.generateTimestamp(buildTask.getBuildOptions().isTimestampAlignment(), buildTask.getBuildSetTask().getStartTime()), buildConfigurationAudited.isBrewPullActive(), buildConfigurationAudited.getDefaultAlignmentParams(), buildTask.getBuildOptions().getAlignmentPreference());
    return new BuildExecutionConfigurationRest(buildExecutionConfiguration);
}
Also used : BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) ToString(lombok.ToString) BuildExecutionConfigurationRest(org.jboss.pnc.bpm.model.BuildExecutionConfigurationRest)

Example 34 with BuildConfigurationAudited

use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.

the class BuildConfigurationProviderImpl method getRevision.

@Override
public BuildConfigurationRevision getRevision(String id, Integer rev) {
    IdRev idRev = new IdRev(Integer.valueOf(id), rev);
    BuildConfigurationAudited auditedBuildConfig = buildConfigurationAuditedRepository.queryById(idRev);
    return buildConfigurationRevisionMapper.toDTO(auditedBuildConfig);
}
Also used : BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) IdRev(org.jboss.pnc.model.IdRev)

Example 35 with BuildConfigurationAudited

use of org.jboss.pnc.model.BuildConfigurationAudited 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)

Aggregations

BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)35 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)12 IdRev (org.jboss.pnc.model.IdRev)12 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)10 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)10 Test (org.junit.Test)8 HashSet (java.util.HashSet)7 BuildRecord (org.jboss.pnc.model.BuildRecord)6 Date (java.util.Date)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 Map (java.util.Map)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 Inject (javax.inject.Inject)4 Base32LongID (org.jboss.pnc.model.Base32LongID)4 Collections (java.util.Collections)3 List (java.util.List)3 Optional (java.util.Optional)3 Stateless (javax.ejb.Stateless)3