use of org.jboss.pnc.dto.GroupBuild in project pnc by project-ncl.
the class GroupBuildProviderTest method testGetSpecific.
@Test
public void testGetSpecific() {
GroupBuild groupBuild = provider.getSpecific(bcsr.getId().toString());
assertThat(groupBuild).isNotNull();
assertThat(groupBuild.getId()).isEqualTo(bcsr.getId().toString());
assertThat(groupBuild.getGroupConfig().getId()).isEqualTo(bcsr.getBuildConfigurationSet().getId().toString());
}
use of org.jboss.pnc.dto.GroupBuild in project bacon by project-ncl.
the class PncBuilderTest method getCountOfBuildConfigsForGroupBuild.
@Test
void getCountOfBuildConfigsForGroupBuild() throws Exception {
Map<String, BuildConfigurationRef> buildConfigurations = new HashMap<>();
BuildConfigurationRef bc1 = easyRandom.nextObject(BuildConfigurationRef.class);
BuildConfigurationRef bc2 = easyRandom.nextObject(BuildConfigurationRef.class);
BuildConfigurationRef bc3 = easyRandom.nextObject(BuildConfigurationRef.class);
buildConfigurations.put(bc1.getName(), bc1);
buildConfigurations.put(bc2.getName(), bc2);
buildConfigurations.put(bc3.getName(), bc3);
String groupConfigurationId = "5";
String groupBuildId = "1";
GroupConfiguration gc = GroupConfiguration.builder().id(groupConfigurationId).buildConfigs(buildConfigurations).build();
GroupBuild gb = GroupBuild.builder().id(groupBuildId).groupConfig(gc).build();
when(groupBuildClient.getSpecific(groupBuildId)).thenReturn(gb);
when(groupConfigurationClient.getBuildConfigs(groupConfigurationId)).thenReturn(new RemoteCollection<BuildConfiguration>() {
@Override
public int size() {
return buildConfigurations.size();
}
@Override
public Collection<BuildConfiguration> getAll() {
return null;
}
@Override
public Iterator<BuildConfiguration> iterator() {
return null;
}
});
try (PncBuilder builder = new PncBuilder(groupBuildClient, groupConfigurationClient)) {
assertEquals(buildConfigurations.size(), builder.getCountOfBuildConfigsForGroupBuild(groupBuildId));
}
}
use of org.jboss.pnc.dto.GroupBuild in project bacon by project-ncl.
the class PigFacade method build.
public static GroupBuildInfo build(boolean tempBuild, boolean tempBuildTS, RebuildMode rebuildMode, boolean wait, boolean dryRun) {
ImportResult importResult = context().getPncImportResult();
if (importResult == null) {
importResult = readPncEntities();
}
if (tempBuild) {
log.info("Temporary build");
}
try (PncBuilder pncBuilder = new PncBuilder()) {
GroupBuild groupBuild = pncBuilder.build(importResult.getBuildGroup(), tempBuild, tempBuildTS, rebuildMode, wait, dryRun);
if (wait) {
try (BuildInfoCollector buildInfoCollector = new BuildInfoCollector()) {
return buildInfoCollector.getBuildsFromGroupBuild(groupBuild);
}
}
log.info("Not waiting for build to finish.");
return null;
}
}
use of org.jboss.pnc.dto.GroupBuild in project bacon by project-ncl.
the class BuildInfoCollector method getBuildsFromGroupBuild.
/**
* Get all the builds done in a build group. If the build finished with 'NO_REBUILD_REQUIRED', get the 'original'
* successful build and return it instead If the build was successful, we don't grab the logs since they can be
* quite long.
*
* @param groupBuild the group build to get the builds
* @return The information on the group build and the builds performed
*/
public GroupBuildInfo getBuildsFromGroupBuild(GroupBuild groupBuild) {
Map<String, PncBuild> result = new HashMap<>();
BuildsFilterParameters filter = new BuildsFilterParameters();
filter.setLatest(false);
filter.setRunning(false);
try {
Collection<Build> builds = groupBuildClient.getBuilds(groupBuild.getId(), filter).getAll();
for (Build build : builds) {
PncBuild pncBuild;
if (build.getStatus() == BuildStatus.NO_REBUILD_REQUIRED) {
BuildRef buildRef = build.getNoRebuildCause();
Build realBuild = buildClient.getSpecific(buildRef.getId());
pncBuild = new PncBuild(realBuild);
} else {
pncBuild = new PncBuild(build);
}
pncBuild.addBuiltArtifacts(toList(buildClient.getBuiltArtifacts(pncBuild.getId())));
result.put(pncBuild.getName(), pncBuild);
}
return new GroupBuildInfo(groupBuild, result);
} catch (RemoteResourceException e) {
throw new RuntimeException("Failed to get group build info for " + groupBuild.getId(), e);
}
}
use of org.jboss.pnc.dto.GroupBuild in project bacon by project-ncl.
the class PncBuilder method cancelRunningGroupBuild.
public String cancelRunningGroupBuild(String groupConfigurationId) {
try {
Collection<GroupBuild> groupBuilds = groupConfigClient.getAllGroupBuilds(groupConfigurationId, of("=desc=startTime"), query("status==%s", BuildStatus.BUILDING)).getAll();
if (groupBuilds.size() > 1) {
return ("Can't cancel, there are multiple GroupBuilds running for single GroupConfiguration name and we can't decide correct one to cancel from build-config.yaml information. Found:" + groupBuilds);
}
if (groupBuilds.isEmpty()) {
return "No build is running for this group.";
}
GroupBuild running = groupBuilds.iterator().next();
groupBuildClient.cancel(running.getId());
return "Group build " + running.getId() + " canceled.";
} catch (RemoteResourceException e) {
throw new RuntimeException("Failed to get group build info to cancel running build.", e);
}
}
Aggregations