use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.
the class LocalBuildScheduler method startBuilding.
@Override
public void startBuilding(BuildTask buildTask) throws CoreException {
Consumer<BuildExecutionStatusChangedEvent> onBuildExecutionStatusChangedEvent = (statusChangedEvent) -> {
try {
log.debug("Received execution status update {}.", statusChangedEvent);
if (statusChangedEvent.getNewStatus().isCompleted()) {
BuildResult buildResult = statusChangedEvent.getBuildResult().get();
log.debug("Notifying build execution completed {}.", statusChangedEvent);
buildCoordinator.completeBuild(buildTask, buildResult);
}
} catch (Throwable t) {
log.error("Failed to notify build completion.", t);
}
};
String contentId = ContentIdentityManager.getBuildContentId(buildTask.getId());
BuildConfigurationAudited configuration = buildTask.getBuildConfigurationAudited();
BuildExecutionConfiguration buildExecutionConfiguration = BuildExecutionConfiguration.build(buildTask.getId(), contentId, buildTask.getUser().getId().toString(), configuration.getBuildScript(), configuration.getId().toString(), configuration.getName(), configuration.getRepositoryConfiguration().getInternalUrl(), configuration.getScmRevision(), null, configuration.getRepositoryConfiguration().getExternalUrl(), configuration.getRepositoryConfiguration().isPreBuildSyncEnabled(), configuration.getBuildEnvironment().getSystemImageId(), configuration.getBuildEnvironment().getSystemImageRepositoryUrl(), configuration.getBuildEnvironment().getSystemImageType(), configuration.getBuildType(), buildTask.getBuildOptions().isKeepPodOnFailure(), configuration.getGenericParameters(), buildTask.getBuildOptions().isTemporaryBuild(), TimeUtils.generateTimestamp(buildTask.getBuildOptions().isTimestampAlignment(), buildTask.getBuildSetTask().getStartTime()), configuration.isBrewPullActive(), configuration.getDefaultAlignmentParams(), buildTask.getBuildOptions().getAlignmentPreference());
try {
buildExecutor.startBuilding(buildExecutionConfiguration, onBuildExecutionStatusChangedEvent, buildTask.getUser().getLoginToken());
} catch (ExecutorException e) {
throw new CoreException("Could not start build execution.", e);
}
}
use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.
the class BuildRecordRepositoryImpl method fetchBuildConfigurationAudited.
private void fetchBuildConfigurationAudited(BuildRecord buildRecord) {
Integer revision = buildRecord.getBuildConfigurationRev();
BuildConfigurationAudited buildConfigurationAudited = buildConfigurationAuditedRepository.queryById(new IdRev(buildRecord.getBuildConfigurationId(), revision));
buildRecord.setBuildConfigurationAudited(buildConfigurationAudited);
}
use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.
the class DefaultDatastore method getLatestBuildConfigurationAuditedLoadBCDependencies.
@Override
public BuildConfigurationAudited getLatestBuildConfigurationAuditedLoadBCDependencies(Integer buildConfigurationId) {
BuildConfigurationAudited buildConfigurationAudited = getLatestBuildConfigurationAudited(buildConfigurationId);
buildConfigurationAudited.setBuildConfiguration(buildConfigurationRepository.queryById(buildConfigurationAudited.getBuildConfiguration().getId()));
buildConfigurationAudited.getBuildConfiguration().getIndirectDependencies();
return buildConfigurationAudited;
}
use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.
the class BuildConfigurationAuditedRepositoryImpl method queryById.
@Override
public Map<IdRev, BuildConfigurationAudited> queryById(Set<IdRev> idRevs) {
logger.trace("Querying for BuildConfigurationAudited.idRevs: {}.", idRevs);
List<String> idRevConcatenated = idRevs.stream().map(idRev -> idRev.getId() + "-" + idRev.getRev()).collect(Collectors.toList());
// WORKAROUND: as I cannot concatenate AuditEntity property to match
// `AuditEntity.property("id")-AuditEntity.property("rev")` in idRevConcatenated list
// I can query all BuildConfigurationAudited with the only id and later on filter id and rev
List<Integer> bcaRevIds = idRevs.stream().map(IdRev::getRev).collect(Collectors.toList());
// Getting all revisions of BuildConfiguration with specified list of IDs
List<Object[]> result = AuditReaderFactory.get(entityManager).createQuery().forRevisionsOfEntity(BuildConfiguration.class, false, false).add(AuditEntity.revisionNumber().in(bcaRevIds)).addOrder(AuditEntity.revisionNumber().desc()).getResultList();
return result.stream().filter(res -> {
BuildConfiguration buildConfiguration = (BuildConfiguration) res[0];
DefaultRevisionEntity revisionEntity = (DefaultRevisionEntity) res[1];
return idRevConcatenated.contains(buildConfiguration.getId() + "-" + revisionEntity.getId());
}).peek(res -> {
BuildConfiguration buildConfiguration = (BuildConfiguration) res[0];
// preload generic parameters
buildConfiguration.getGenericParameters().forEach((k, v) -> k.equals(null));
}).map(res -> {
BuildConfiguration buildConfiguration = (BuildConfiguration) res[0];
DefaultRevisionEntity revisionEntity = (DefaultRevisionEntity) res[1];
return BuildConfigurationAudited.fromBuildConfiguration(buildConfiguration, revisionEntity.getId());
}).collect(Collectors.toMap(BuildConfigurationAudited::getIdRev, bca -> bca));
}
use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.
the class BuildBCRevisionFetcher method mapFromAuditedBuildConfig.
@BeforeMapping
public void mapFromAuditedBuildConfig(BuildRecord build, @MappingTarget Build.Builder dtoBuilder) {
Integer id = build.getBuildConfigurationId();
Integer revision = build.getBuildConfigurationRev();
// If somebody before us already set the BCA we don't need to query it from DB again
BuildConfigurationAudited bca = build.getBuildConfigurationAudited();
if (bca == null) {
bca = bcAuditedRepository.queryById(new IdRev(id, revision));
}
BuildConfigurationRevisionRef bcRevision = bcRevisionMapper.toRef(bca);
ProjectRef project = projectMapper.toRef(bca.getProject());
Environment environment = environmentMapper.toRef(bca.getBuildEnvironment());
SCMRepository scmRepository = scmRepositoryMapper.toRef(bca.getRepositoryConfiguration());
dtoBuilder.buildConfigRevision(bcRevision);
dtoBuilder.project(project);
dtoBuilder.environment(environment);
dtoBuilder.scmRepository(scmRepository);
}
Aggregations