use of org.jboss.pnc.dto.BuildConfiguration in project bacon by project-ncl.
the class PncEntitiesImporter method generatePncBuildConfig.
/**
* @param buildConfig PiG buildconfig to generate
* @param existing if present, we'll use it as the buildconfig to modify if null: we'll use a fresh buildconfig
* object
*
* @return BuildConfiguration generated
*/
private BuildConfiguration generatePncBuildConfig(BuildConfig buildConfig, BuildConfiguration existing) {
ProjectRef project = getOrGenerateProject(buildConfig.getProject());
SCMRepository repository = getOrGenerateRepository(buildConfig);
Environment environment = Environment.builder().id(buildConfig.getEnvironmentId()).build();
BuildConfiguration.Builder builder = BuildConfiguration.builder();
if (existing != null) {
builder = existing.toBuilder();
}
return builder.productVersion(version).parameters(buildConfig.getGenericParameters(null, false)).name(buildConfig.getName()).project(project).environment(environment).scmRepository(repository).scmRevision(buildConfig.getScmRevision()).buildScript(buildConfig.getBuildScript()).buildType(BuildType.valueOf(buildConfig.getBuildType())).brewPullActive(buildConfig.getBrewPullActive()).build();
}
use of org.jboss.pnc.dto.BuildConfiguration in project bacon by project-ncl.
the class PncEntitiesImporter method updateBuildConfig.
private BuildConfiguration updateBuildConfig(BuildConfigData data, BuildConfiguration existing) {
String configId = data.getId();
BuildConfiguration buildConfiguration = generatePncBuildConfig(data.getNewConfig(), existing);
try {
buildConfigClient.update(configId, buildConfiguration);
return buildConfigClient.getSpecific(configId);
} catch (ClientException e) {
throw new RuntimeException("Failed to update build configuration " + configId, e);
}
}
use of org.jboss.pnc.dto.BuildConfiguration in project bacon by project-ncl.
the class PncEntitiesImporter method updateOrCreate.
private List<BuildConfigData> updateOrCreate(List<BuildConfiguration> currentConfigs, List<BuildConfig> builds, boolean skipBranchCheck, boolean temporaryBuild) {
List<BuildConfigData> buildList = new ArrayList<>();
for (BuildConfig bc : builds) {
BuildConfigData data = new BuildConfigData(bc);
for (BuildConfiguration config : currentConfigs) {
if (config.getName().equals(bc.getName())) {
data.setOldConfig(config);
data.setId(config.getId());
if (data.shouldBeUpdated(skipBranchCheck, temporaryBuild)) {
updateBuildConfig(data, config);
}
}
}
// Check if build exists already (globally)
// True = Add to BCS and update BC (maybe ask?)
Optional<BuildConfiguration> matchedBuildConfig = getBuildConfigFromName(bc.getName());
if (matchedBuildConfig.isPresent()) {
log.debug("Found matching build config for {}", bc.getName());
data.setOldConfig(matchedBuildConfig.get());
data.setId(matchedBuildConfig.get().getId());
if (data.shouldBeUpdated(skipBranchCheck, temporaryBuild)) {
updateBuildConfig(data, matchedBuildConfig.get());
}
data.setModified(true);
} else {
log.debug("No matching build config found in the BCS");
// False = Create new project/BC
BuildConfiguration createdConfig = createBuildConfig(data.getNewConfig());
data.setId(createdConfig.getId());
data.setModified(true);
log.debug("Didn't find matching build config for {}", bc.getName());
}
buildList.add(data);
}
return buildList;
}
use of org.jboss.pnc.dto.BuildConfiguration in project bacon by project-ncl.
the class BuildConfigMappingTest method testPigYamlMetadataSet.
@Test
void testPigYamlMetadataSet() {
Map<String, String> parameters = new HashMap<>();
parameters.put("PIG_YAML_METADATA", "12345");
BuildConfiguration buildConfiguration = BuildConfiguration.builder().parameters(parameters).build();
BuildConfigMapping.setBuildConfigFieldsBasedOnParameters(buildConfiguration, buildConfig);
assertEquals("12345", buildConfig.getPigYamlMetadata());
// make sure no other parameters are set
assertTrue(buildConfig.getAlignmentParameters().size() == 0);
assertNull(buildConfig.getBuildPodMemory());
assertNull(buildConfig.getBuildCategory());
assertNull(buildConfig.getBrewBuildName());
assertTrue(buildConfig.getExtraRepositories().size() == 0);
}
use of org.jboss.pnc.dto.BuildConfiguration in project bacon by project-ncl.
the class BuildConfigMappingTest method testCanSetMultipleParameters.
@Test
void testCanSetMultipleParameters() {
Map<String, String> parameters = new HashMap<>();
parameters.put("ALIGNMENT_PARAMETERS", "-Dtest=true -Dme=false");
parameters.put("BREW_BUILD_NAME", "testme");
BuildConfiguration buildConfiguration = BuildConfiguration.builder().parameters(parameters).build();
BuildConfigMapping.setBuildConfigFieldsBasedOnParameters(buildConfiguration, buildConfig);
assertEquals("-Dtest=true -Dme=false", buildConfig.getAlignmentParameters().stream().findFirst().get());
assertEquals("testme", buildConfig.getBrewBuildName());
// make sure no other parameters are set
assertNull(buildConfig.getBuildPodMemory());
assertNull(buildConfig.getBuildCategory());
assertNull(buildConfig.getPigYamlMetadata());
assertTrue(buildConfig.getExtraRepositories().size() == 0);
}
Aggregations