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;
}
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");
}
}
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);
}
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);
}
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;
}
Aggregations