Search in sources :

Example 1 with BuildType

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.");
    }
}
Also used : RepositoryType(org.jboss.pnc.enums.RepositoryType) BuildType(org.jboss.pnc.enums.BuildType) BuildExecution(org.jboss.pnc.spi.repositorymanager.BuildExecution) RepositoryManager(org.jboss.pnc.spi.repositorymanager.RepositoryManager) RepositorySession(org.jboss.pnc.spi.repositorymanager.model.RepositorySession) BuildProcessException(org.jboss.pnc.executor.exceptions.BuildProcessException)

Example 2 with BuildType

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);
}
Also used : BuildImportRequest(org.jboss.pnc.api.causeway.dto.push.BuildImportRequest) Request(org.jboss.pnc.api.dto.Request) BuildImportRequest(org.jboss.pnc.api.causeway.dto.push.BuildImportRequest) Dependency(org.jboss.pnc.api.causeway.dto.push.Dependency) Artifact(org.jboss.pnc.model.Artifact) BuiltArtifact(org.jboss.pnc.api.causeway.dto.push.BuiltArtifact) MavenBuiltArtifact(org.jboss.pnc.api.causeway.dto.push.MavenBuiltArtifact) NpmBuiltArtifact(org.jboss.pnc.api.causeway.dto.push.NpmBuiltArtifact) BuiltArtifact(org.jboss.pnc.api.causeway.dto.push.BuiltArtifact) MavenBuiltArtifact(org.jboss.pnc.api.causeway.dto.push.MavenBuiltArtifact) NpmBuiltArtifact(org.jboss.pnc.api.causeway.dto.push.NpmBuiltArtifact) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildEnvironment(org.jboss.pnc.model.BuildEnvironment) Build(org.jboss.pnc.api.causeway.dto.push.Build) MavenBuild(org.jboss.pnc.api.causeway.dto.push.MavenBuild) NpmBuild(org.jboss.pnc.api.causeway.dto.push.NpmBuild) BuildType(org.jboss.pnc.enums.BuildType) BuildRoot(org.jboss.pnc.api.causeway.dto.push.BuildRoot)

Example 3 with BuildType

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();
        }
    }
}
Also used : BuildType(org.jboss.pnc.enums.BuildType) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) AlignmentParameters(org.jboss.pnc.dto.response.AlignmentParameters) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 4 with BuildType

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);
    }
}
Also used : GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup) Group(org.commonjava.indy.model.core.Group) BuildType(org.jboss.pnc.enums.BuildType) ArtifactRepository(org.jboss.pnc.spi.repositorymanager.ArtifactRepository) StoreKey(org.commonjava.indy.model.core.StoreKey) HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Example 5 with BuildType

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);
}
Also used : BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) Base32LongID(org.jboss.pnc.model.Base32LongID) BuildCategory(org.jboss.pnc.enums.BuildCategory) Indy(org.commonjava.indy.client.core.Indy) BuildType(org.jboss.pnc.enums.BuildType) BuildRecord(org.jboss.pnc.model.BuildRecord)

Aggregations

BuildType (org.jboss.pnc.enums.BuildType)6 Indy (org.commonjava.indy.client.core.Indy)2 Group (org.commonjava.indy.model.core.Group)2 StoreKey (org.commonjava.indy.model.core.StoreKey)2 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)2 IndyClientException (org.commonjava.indy.client.core.IndyClientException)1 IndyStoresClientModule (org.commonjava.indy.client.core.module.IndyStoresClientModule)1 IndyFoloAdminClientModule (org.commonjava.indy.folo.client.IndyFoloAdminClientModule)1 BatchDeleteRequest (org.commonjava.indy.model.core.BatchDeleteRequest)1 HostedRepository (org.commonjava.indy.model.core.HostedRepository)1 Build (org.jboss.pnc.api.causeway.dto.push.Build)1 BuildImportRequest (org.jboss.pnc.api.causeway.dto.push.BuildImportRequest)1 BuildRoot (org.jboss.pnc.api.causeway.dto.push.BuildRoot)1 BuiltArtifact (org.jboss.pnc.api.causeway.dto.push.BuiltArtifact)1 Dependency (org.jboss.pnc.api.causeway.dto.push.Dependency)1 MavenBuild (org.jboss.pnc.api.causeway.dto.push.MavenBuild)1 MavenBuiltArtifact (org.jboss.pnc.api.causeway.dto.push.MavenBuiltArtifact)1 NpmBuild (org.jboss.pnc.api.causeway.dto.push.NpmBuild)1 NpmBuiltArtifact (org.jboss.pnc.api.causeway.dto.push.NpmBuiltArtifact)1 Request (org.jboss.pnc.api.dto.Request)1