use of org.jboss.pnc.enums.BuildType in project pnc by project-ncl.
the class DefaultBuildExecutor method configureRepository.
private RepositorySession configureRepository(DefaultBuildExecutionSession buildExecutionSession) {
if (buildExecutionSession.isCanceled()) {
return null;
}
ProcessStageUtils.logProcessStageBegin(BuildExecutionStatus.REPO_SETTING_UP.toString(), "Setting up repository...");
buildExecutionSession.setStatus(BuildExecutionStatus.REPO_SETTING_UP);
BuildType buildType = buildExecutionSession.getBuildExecutionConfiguration().getBuildType();
if (buildType == null) {
throw new BuildProcessException("Missing required value buildExecutionConfiguration.buildType");
}
RepositoryType repositoryType = BuildTypeToRepositoryType.getRepositoryType(buildType);
try {
RepositoryManager repositoryManager = repositoryManagerFactory.getRepositoryManager(repositoryType);
BuildExecution buildExecution = buildExecutionSession.getBuildExecutionConfiguration();
String serviceAccountToken = (serviceClient == null ? null : serviceClient.getAuthToken());
RepositorySession buildRepository = repositoryManager.createBuildRepositoryWithRetries(buildExecution, buildExecutionSession.getAccessToken(), serviceAccountToken, repositoryType, buildExecutionSession.getBuildExecutionConfiguration().getGenericParameters(), buildExecutionSession.getBuildExecutionConfiguration().isBrewPullActive());
return buildRepository;
} catch (Throwable e) {
throw new BuildProcessException(e);
} finally {
ProcessStageUtils.logProcessStageEnd(BuildExecutionStatus.REPO_SETTING_UP.toString(), "Repository setup complete.");
}
}
use of org.jboss.pnc.enums.BuildType 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);
}
use of org.jboss.pnc.enums.BuildType in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method testGetBuildTypeDefaultAlignmentParameters.
@Test
public void testGetBuildTypeDefaultAlignmentParameters() throws RemoteResourceException {
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
for (BuildType buildType : BuildType.values()) {
AlignmentParameters params = client.getBuildTypeDefaultAlignmentParameters(buildType.name());
// NPM and SBT default alignment params are empty
if (!BuildType.NPM.equals(buildType) && !BuildType.SBT.equals(buildType)) {
assertThat(params.getParameters()).isNotEmpty();
assertThat(params.getBuildType()).isNotEmpty();
}
}
}
use of org.jboss.pnc.enums.BuildType in project pnc by project-ncl.
the class RepositoryManagerDriver method setupBuildRepos.
/**
* Create the hosted repository and group necessary to support a single build. The hosted repository holds artifacts
* uploaded from the build, and the group coordinates access to this hosted repository, along with content from the
* product-level content group with which this build is associated. The group also provides a tracking target, so
* the repository manager can keep track of downloads and uploads for the build.
*
* @param execution The execution object, which contains the content id for creating the repo, and the build id.
* @param packageType the package type key used by Indy
* @throws IndyClientException
*/
private void setupBuildRepos(BuildExecution execution, String packageType, Indy indy, Map<String, String> genericParameters, boolean brewPullActive) throws IndyClientException {
String buildContentId = execution.getBuildContentId();
String id = execution.getId();
BuildType buildType = execution.getBuildType();
// if the build-level group doesn't exist, create it.
StoreKey groupKey = new StoreKey(packageType, StoreType.group, buildContentId);
StoreKey hostedKey = new StoreKey(packageType, StoreType.hosted, buildContentId);
if (!indy.stores().exists(groupKey)) {
// if the product-level storage repo (for in-progress product builds) doesn't exist, create it.
boolean tempBuild = execution.isTempBuild();
if (!indy.stores().exists(hostedKey)) {
HostedRepository buildArtifacts = new HostedRepository(packageType, buildContentId);
buildArtifacts.setAllowSnapshots(false);
buildArtifacts.setAllowReleases(true);
buildArtifacts.setDescription(String.format("Build output for PNC %s build #%s", packageType, id));
indy.stores().create(buildArtifacts, "Creating hosted repository for " + packageType + " build: " + id + " (repo: " + buildContentId + ")", HostedRepository.class);
}
Group buildGroup = new Group(packageType, buildContentId);
String adjective = tempBuild ? "temporary " : "";
buildGroup.setDescription(String.format("Aggregation group for PNC %sbuild #%s", adjective, id));
// build-local artifacts
buildGroup.addConstituent(hostedKey);
// [MMENG-1262] set if brew pull is active or not via group metadata
buildGroup.setMetadata(BREW_PULL_ACTIVE_METADATA_KEY, Boolean.toString(brewPullActive));
// Global-level repos, for captured/shared artifacts and access to the outside world
addGlobalConstituents(buildType, packageType, buildGroup, tempBuild);
// add extra repositories removed from poms by the adjust process and set in BC by user
List<ArtifactRepository> extraDependencyRepositories = extractExtraRepositoriesFromGenericParameters(genericParameters);
if (execution.getArtifactRepositories() != null) {
extraDependencyRepositories.addAll(execution.getArtifactRepositories());
}
addExtraConstituents(packageType, extraDependencyRepositories, id, buildContentId, indy, buildGroup);
String changelog = "Creating repository group for resolving artifacts in build: " + id + " (repo: " + buildContentId + ")";
indy.stores().create(buildGroup, changelog, Group.class);
}
}
use of org.jboss.pnc.enums.BuildType in project pnc by project-ncl.
the class RepositoryManagerDriver method collectRepoManagerResult.
@Override
public RepositoryManagerResult collectRepoManagerResult(String id) throws RepositoryManagerException {
Base32LongID buildId = new Base32LongID(id);
BuildRecord br = buildRecordRepository.findByIdFetchProperties(buildId);
if (br == null) {
return null;
}
BuildConfigurationAudited bc = br.getBuildConfigurationAudited();
String buildContentId = br.getBuildContentId();
BuildType buildType = bc.getBuildType();
boolean tempBuild = br.isTemporaryBuild();
Indy indy = init(null);
String buildPromotionTarget = tempBuild ? TEMP_BUILD_PROMOTION_TARGET : BUILD_PROMOTION_TARGET;
String packageType = getIndyPackageTypeKey(buildType.getRepoType());
BuildCategory buildCategory = getBuildCategory(bc.getGenericParameters());
ArtifactFilter artifactFilter = new ArtifactFilterImpl(ignoredPathPatternsPromotion, ignoredPathPatternsData, ignoredRepoPatterns);
IndyRepositorySession session = new IndyRepositorySession(indy, indy, buildContentId, packageType, null, artifactFilter, buildPromotionTarget, buildCategory, tempBuild);
return session.extractBuildArtifacts(false);
}
Aggregations