use of org.jboss.pnc.model.BuildConfigSetRecord in project pnc by project-ncl.
the class TemporaryBuildsCleaner method deleteTemporaryBuildConfigSetRecord.
/**
* Deletes a BuildConfigSetRecord and BuildRecords produced in the build
*
* @param buildConfigSetRecordId BuildConfigSetRecord to be deleted
* @param authToken
*/
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public Result deleteTemporaryBuildConfigSetRecord(Integer buildConfigSetRecordId, String authToken) throws ValidationException {
BuildConfigSetRecord buildConfigSetRecord = buildConfigSetRecordRepository.queryById(buildConfigSetRecordId);
if (buildConfigSetRecord == null) {
throw new ValidationException("Cannot delete temporary BuildConfigSetRecord with id " + buildConfigSetRecordId + " as no BuildConfigSetRecord with this id exists");
}
if (!buildConfigSetRecord.isTemporaryBuild()) {
throw new ValidationException("Only deletion of the temporary builds is allowed");
}
log.info("Starting deletion of a temporary build record set " + buildConfigSetRecord);
for (BuildRecord br : buildConfigSetRecord.getBuildRecords()) {
br.setBuildConfigSetRecord(null);
buildRecordRepository.save(br);
}
buildConfigSetRecordRepository.delete(buildConfigSetRecord.getId());
log.info("Deletion of a temporary build record set {} finished successfully.", buildConfigSetRecord);
return new Result(buildConfigSetRecordId.toString(), ResultStatus.SUCCESS);
}
use of org.jboss.pnc.model.BuildConfigSetRecord in project pnc by project-ncl.
the class BuildTask method build.
public static BuildTask build(BuildConfigurationAudited buildConfigurationAudited, BuildOptions buildOptions, User user, String buildTaskId, BuildSetTask buildSetTask, Date submitTime, ProductMilestone productMilestone, String contentId, Optional<String> requestContext) {
Integer buildConfigSetRecordId = null;
if (buildSetTask != null) {
buildConfigSetRecordId = buildSetTask.getBuildConfigSetRecord().map(BuildConfigSetRecord::getId).orElse(null);
}
ProductMilestone milestone = productMilestone;
if (milestone != null && milestone.getEndDate() != null) {
userLog.warn("Not using current milestone {} for build task {}, because the milestone is closed.", productMilestone, buildTaskId);
milestone = null;
}
return new BuildTask(buildConfigurationAudited, buildOptions, user, submitTime, buildSetTask, buildTaskId, buildConfigSetRecordId, milestone, contentId, requestContext);
}
use of org.jboss.pnc.model.BuildConfigSetRecord in project pnc by project-ncl.
the class GroupBuildProviderTest method prepareBCSetRecord.
private BuildConfigSetRecord prepareBCSetRecord(BuildConfigurationSet buildConfigurationSet) {
final BuildConfigSetRecord record = BuildConfigSetRecord.Builder.newBuilder().id(entityId.getAndIncrement()).buildConfigurationSet(buildConfigurationSet).startTime(Date.from(Instant.now())).user(mockUser()).temporaryBuild(false).build();
buildConfigurationSet.addBuildConfigSetRecord(record);
return record;
}
use of org.jboss.pnc.model.BuildConfigSetRecord in project pnc by project-ncl.
the class BuildProviderImpl method getBuildGraphForGroupBuild.
@Override
public Graph<Build> getBuildGraphForGroupBuild(String groupBuildId) {
BuildConfigSetRecord buildConfigSetRecord = buildConfigSetRecordRepository.queryById(Integer.valueOf(groupBuildId));
if (buildConfigSetRecord == null) {
throw new EmptyEntityException("Build group " + groupBuildId + " does not exists.");
}
List<String> runningAndStoredIds = getBuildIdsInTheGroup(buildConfigSetRecord);
org.jboss.util.graph.Graph<BuildWithDependencies> buildGraph = new org.jboss.util.graph.Graph<>();
for (String buildId : runningAndStoredIds) {
org.jboss.util.graph.Graph<BuildWithDependencies> dependencyGraph = createBuildDependencyGraph(buildId);
GraphUtils.merge(buildGraph, dependencyGraph);
logger.trace("Merged graph from buildRecordId {} to BuildConfigSetRecordGraph {}; Edges {},", buildId, buildGraph, buildGraph.getEdges());
}
GraphDtoBuilder<BuildWithDependencies, Build> graphBuilder = new GraphDtoBuilder();
Graph<Build> graphDto = graphBuilder.from(buildGraph, Build.class, vertex -> vertex.getData().getBuild());
return graphDto;
}
use of org.jboss.pnc.model.BuildConfigSetRecord in project pnc by project-ncl.
the class StatusUpdatesTest method BuildTaskCallbacksShouldBeCalled.
@Test
@InSequence(30)
public void BuildTaskCallbacksShouldBeCalled() throws DatastoreException, CoreException {
User user = User.Builder.newBuilder().id(3).username("test-user-3").build();
Set<BuildTask> buildTasks = initializeBuildTaskSet(configurationBuilder, user, (buildConfigSetRecord) -> {
}).getBuildTasks();
Set<String> tasksIds = buildTasks.stream().map((BuildTask::getId)).collect(Collectors.toSet());
Set<String> receivedUpdatesForId = new HashSet<>();
Consumer<BuildStatusChangedEvent> statusChangeEventConsumer = (statusChangedEvent) -> {
receivedUpdatesForId.add(statusChangedEvent.getBuild().getId());
};
tasksIds.forEach((id) -> buildStatusNotifications.subscribe(new BuildCallBack(id, statusChangeEventConsumer)));
buildTasks.forEach((bt) -> buildCoordinator.updateBuildTaskStatus(bt, BuildCoordinationStatus.DONE));
System.out.println("Received updates: " + receivedUpdatesForId);
tasksIds.forEach((id) -> Assert.assertTrue("Did not receive update for task " + id, receivedUpdatesForId.contains(id)));
}
Aggregations