use of org.jboss.pnc.api.causeway.dto.push.BuiltArtifact in project pnc by project-ncl.
the class BuildResultPushManager method createCausewayPushRequest.
private BuildImportRequest createCausewayPushRequest(BuildRecord buildRecord, String tagPrefix, URI callBackUrl, String authToken, Long pushResultId, boolean reimport) {
BuildEnvironment buildEnvironment = buildRecord.getBuildConfigurationAudited().getBuildEnvironment();
logger.debug("BuildRecord: {}", buildRecord.getId());
logger.debug("BuildEnvironment: {}", buildEnvironment);
BuildRoot buildRoot = BuildRoot.builder().container("DOCKER_IMAGE").containerArchitecture(// TODO set based on env, some env has native build tools
"x86_64").host("rhel").hostArchitecture("x86_64").tools(buildEnvironment.getAttributes()).build();
List<Artifact> builtArtifactEntities = artifactRepository.queryWithPredicates(ArtifactPredicates.withBuildRecordId(buildRecord.getId()));
List<Artifact> dependencyEntities = artifactRepository.queryWithPredicates(ArtifactPredicates.withDependantBuildRecordId(buildRecord.getId()));
logger.debug("Preparing BuildImportRequest containing {} built artifacts and {} dependencies.", builtArtifactEntities.size(), dependencyEntities.size());
BuildType buildType = buildRecord.getBuildConfigurationAudited().getBuildType();
Set<Dependency> dependencies = collectDependencies(dependencyEntities);
Set<BuiltArtifact> builtArtifacts = collectBuiltArtifacts(builtArtifactEntities, buildType);
Map<String, String> callbackHeaders = Collections.singletonMap(MDCUtils.getMDCToHeaderMappings().get(MDCKeys.PROCESS_CONTEXT_KEY), pushResultId.toString());
Request callbackTarget = Request.builder().method(Request.Method.POST).authTokenHeader(authToken).uri(callBackUrl).header(MDCUtils.getMDCToHeaderMappings().get(MDCKeys.PROCESS_CONTEXT_KEY), pushResultId.toString()).build();
String executionRootName = buildRecord.getExecutionRootName();
// prefer execution root name from generic parameters
BuildConfigurationAudited buildConfigurationAudited = buildConfigurationAuditedRepository.queryById(buildRecord.getBuildConfigurationAuditedIdRev());
Map<String, String> genericParameters = buildConfigurationAudited.getGenericParameters();
if (executionRootName == null) {
if (genericParameters.containsKey(BREW_BUILD_NAME.name())) {
executionRootName = genericParameters.get(BREW_BUILD_NAME.name());
} else {
throw new IllegalArgumentException("Provided build " + buildRecord.getId() + " is missing brew name. Please set build attribute " + BUILD_BREW_NAME + ".");
}
}
Build build = getBuild(buildRecord, tagPrefix, buildRoot, dependencies, builtArtifacts, executionRootName, buildType);
return new BuildImportRequest(callbackTarget, build, reimport);
}
Aggregations