use of org.jboss.pnc.dto.Environment in project pnc by project-ncl.
the class RemoteBuildTest method getOrCreateBuildConfiguration.
private BuildConfiguration getOrCreateBuildConfiguration(String buildConfigurationName, String buildScript, String scmRevision, Map<String, String> genericParameters, String projectId, String repositoryConfigurationId, String buildEnvironmentId) throws RemoteResourceException {
RemoteCollection<BuildConfiguration> existing = buildConfigurationRestClient.getAll(Optional.empty(), Optional.of("name==" + buildConfigurationName));
Iterator<BuildConfiguration> it = existing.iterator();
if (!it.hasNext()) {
ProjectRef project = ProjectRef.refBuilder().id(projectId).build();
SCMRepository repository = SCMRepository.builder().id(repositoryConfigurationId).build();
Environment environment = Environment.builder().id(buildEnvironmentId).build();
BuildConfiguration buildConfiguration = BuildConfiguration.builder().name(buildConfigurationName).project(project).scmRepository(repository).scmRevision(scmRevision).environment(environment).buildScript(buildScript).parameters(genericParameters).build();
BuildConfiguration created = buildConfigurationRestClient.createNew(buildConfiguration);
return created;
} else {
return it.next();
}
}
use of org.jboss.pnc.dto.Environment in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method shouldNotCreateWhenEnvironmentDoesNotExist.
@Test
public void shouldNotCreateWhenEnvironmentDoesNotExist() throws ClientException {
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
BuildConfiguration bc = client.getSpecific(configurationId);
Environment origEnv = bc.getEnvironment();
Environment env = Environment.builder().attributes(origEnv.getAttributes()).deprecated(origEnv.isDeprecated()).description(origEnv.getDescription()).name(origEnv.getName()).systemImageId(origEnv.getSystemImageId()).systemImageRepositoryUrl(origEnv.getSystemImageRepositoryUrl()).systemImageType(origEnv.getSystemImageType()).id("10000").build();
BuildConfiguration newBC = BuildConfiguration.builder().name("othernameforbc2").buildScript(bc.getBuildScript()).project(bc.getProject()).environment(env).parameters(bc.getParameters()).buildType(bc.getBuildType()).scmRepository(bc.getScmRepository()).scmRevision(bc.getScmRevision()).build();
assertThatThrownBy(() -> client.createNew(newBC)).hasCauseInstanceOf(NotFoundException.class);
}
use of org.jboss.pnc.dto.Environment in project pnc by project-ncl.
the class EnvironmentEndpointTest method testQueryForEnvironment.
@Test
@InSequence(20)
public void testQueryForEnvironment() throws RemoteResourceException {
EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Environment> allNonDeprecated = client.getAll(Optional.empty(), Optional.of("deprecated==false"));
RemoteCollection<Environment> allDeprecated = client.getAll(Optional.empty(), Optional.of("deprecated==true"));
assertThat(allNonDeprecated.getAll().stream().map(Environment::isDeprecated)).containsOnly(false);
assertThat(allDeprecated.getAll().stream().map(Environment::isDeprecated)).containsOnly(true);
}
use of org.jboss.pnc.dto.Environment 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);
}
use of org.jboss.pnc.dto.Environment 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();
}
Aggregations