Search in sources :

Example 1 with BuildExecution

use of org.jboss.pnc.spi.repositorymanager.BuildExecution 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 BuildExecution

use of org.jboss.pnc.spi.repositorymanager.BuildExecution in project pnc by project-ncl.

the class BuildGroupIncludesProductVersionGroupTest method verifyGroupComposition_ProductVersion_NoConfSet.

@Test
public void verifyGroupComposition_ProductVersion_NoConfSet() throws Exception {
    // create a dummy non-chained build execution and repo session based on it
    BuildExecution execution = new TestBuildExecution("build_myproject_12345");
    Indy indy = driver.getIndy(accessToken);
    RepositorySession repositoryConfiguration = driver.createBuildRepository(execution, accessToken, accessToken, RepositoryType.MAVEN, Collections.emptyMap(), false);
    String repoId = repositoryConfiguration.getBuildRepositoryId();
    assertThat(repoId, equalTo(execution.getBuildContentId()));
    // check that the build group includes:
    // - the build's hosted repo
    // - the product version repo group
    // - the "shared-releases" repo group
    // - the "shared-imports" repo
    // - the public group
    // ...in that order
    Group buildGroup = indy.stores().load(new StoreKey(MAVEN_PKG_KEY, StoreType.group, repoId), Group.class);
    System.out.printf("Constituents:\n  %s\n", join(buildGroup.getConstituents(), "\n  "));
    assertGroupConstituents(buildGroup, new StoreKey(MAVEN_PKG_KEY, StoreType.hosted, execution.getBuildContentId()), new StoreKey(MAVEN_PKG_KEY, StoreType.group, IndyRepositoryConstants.COMMON_BUILD_GROUP_CONSTITUENTS_GROUP));
}
Also used : Group(org.commonjava.indy.model.core.Group) TestBuildExecution(org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution) Indy(org.commonjava.indy.client.core.Indy) TestBuildExecution(org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution) BuildExecution(org.jboss.pnc.spi.repositorymanager.BuildExecution) RepositorySession(org.jboss.pnc.spi.repositorymanager.model.RepositorySession) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest)

Example 3 with BuildExecution

use of org.jboss.pnc.spi.repositorymanager.BuildExecution in project pnc by project-ncl.

the class BuildGroupIndySidecarActivatedTest method verifyGroupComposition_ProductVersion_WithConfSet.

@Test
public void verifyGroupComposition_ProductVersion_WithConfSet() throws Exception {
    // create a dummy composed (chained) build execution and a repo session based on it
    BuildExecution execution = new TestBuildExecution("build_myproject_1111");
    Indy indy = driver.getIndy(accessToken);
    RepositorySession repositoryConfiguration = driver.createBuildRepository(execution, accessToken, accessToken, RepositoryType.MAVEN, Collections.emptyMap(), false);
    RepositoryConnectionInfo info = repositoryConfiguration.getConnectionInfo();
    assertThat(info.getDependencyUrl()).startsWith(sideCarUrl);
    assertThat(info.getDeployUrl()).startsWith(sideCarUrl);
}
Also used : TestBuildExecution(org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution) Indy(org.commonjava.indy.client.core.Indy) TestBuildExecution(org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution) BuildExecution(org.jboss.pnc.spi.repositorymanager.BuildExecution) RepositoryConnectionInfo(org.jboss.pnc.spi.repositorymanager.model.RepositoryConnectionInfo) RepositorySession(org.jboss.pnc.spi.repositorymanager.model.RepositorySession) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 4 with BuildExecution

use of org.jboss.pnc.spi.repositorymanager.BuildExecution in project pnc by project-ncl.

the class BuildGroupIndySidecarDeActivatedTest method verifyGroupComposition_ProductVersion_WithConfSet.

@Test
public void verifyGroupComposition_ProductVersion_WithConfSet() throws Exception {
    // create a dummy composed (chained) build execution and a repo session based on it
    BuildExecution execution = new TestBuildExecution("build_myproject_1111");
    Indy indy = driver.getIndy(accessToken);
    RepositorySession repositoryConfiguration = driver.createBuildRepository(execution, accessToken, accessToken, RepositoryType.MAVEN, Collections.emptyMap(), false);
    RepositoryConnectionInfo info = repositoryConfiguration.getConnectionInfo();
    assertThat(info.getDependencyUrl()).doesNotStartWith(sideCarUrl);
    assertThat(info.getDeployUrl()).doesNotStartWith(sideCarUrl);
}
Also used : TestBuildExecution(org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution) Indy(org.commonjava.indy.client.core.Indy) TestBuildExecution(org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution) BuildExecution(org.jboss.pnc.spi.repositorymanager.BuildExecution) RepositoryConnectionInfo(org.jboss.pnc.spi.repositorymanager.model.RepositoryConnectionInfo) RepositorySession(org.jboss.pnc.spi.repositorymanager.model.RepositorySession) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 5 with BuildExecution

use of org.jboss.pnc.spi.repositorymanager.BuildExecution in project pnc by project-ncl.

the class DependencyUrlIncludesTrackingIdAndGeneratedBuildGroupNameTest method formatRepositoryURLForSimpleInfo_CheckDependencyURL.

@Test
public void formatRepositoryURLForSimpleInfo_CheckDependencyURL() throws Exception {
    // create a dummy non-chained build execution and repo session based on it
    BuildExecution execution = new TestBuildExecution();
    RepositorySession repositoryConfiguration = driver.createBuildRepository(execution, accessToken, accessToken, RepositoryType.MAVEN, Collections.emptyMap(), false);
    assertThat(repositoryConfiguration, notNullValue());
    // verify the URLs in the connection info reference this build, and refer to a tracked repository group URL
    RepositoryConnectionInfo connectionInfo = repositoryConfiguration.getConnectionInfo();
    assertThat(connectionInfo, notNullValue());
    String expectedUrlPrefix = String.format("%sfolo/track/%s", url, execution.getBuildContentId());
    String expectedGroupPathPrefix = String.format("/group/%s", execution.getBuildContentId());
    assertThat("Expected URL prefix: " + expectedUrlPrefix + "\nActual URL was: " + connectionInfo.getDependencyUrl(), connectionInfo.getDependencyUrl().startsWith(expectedUrlPrefix), equalTo(true));
    assertThat("Expected URL to contain group path prefix: " + expectedGroupPathPrefix + "\nActual URL was: " + connectionInfo.getDependencyUrl(), connectionInfo.getDependencyUrl().contains(expectedGroupPathPrefix), equalTo(true));
}
Also used : TestBuildExecution(org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution) TestBuildExecution(org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution) BuildExecution(org.jboss.pnc.spi.repositorymanager.BuildExecution) RepositoryConnectionInfo(org.jboss.pnc.spi.repositorymanager.model.RepositoryConnectionInfo) RepositorySession(org.jboss.pnc.spi.repositorymanager.model.RepositorySession) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

BuildExecution (org.jboss.pnc.spi.repositorymanager.BuildExecution)20 RepositorySession (org.jboss.pnc.spi.repositorymanager.model.RepositorySession)20 TestBuildExecution (org.jboss.pnc.indyrepositorymanager.fixture.TestBuildExecution)19 ContainerTest (org.jboss.pnc.test.category.ContainerTest)18 Test (org.junit.Test)18 StoreKey (org.commonjava.indy.model.core.StoreKey)12 Artifact (org.jboss.pnc.model.Artifact)11 RepositoryManagerResult (org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult)11 Indy (org.commonjava.indy.client.core.Indy)8 Group (org.commonjava.indy.model.core.Group)7 File (java.io.File)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ProjectVersionRef (org.commonjava.atlas.maven.ident.ref.ProjectVersionRef)4 SimpleArtifactRef (org.commonjava.atlas.maven.ident.ref.SimpleArtifactRef)4 SimpleProjectVersionRef (org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef)4 IndyFoloContentClientModule (org.commonjava.indy.folo.client.IndyFoloContentClientModule)4 RepositoryConnectionInfo (org.jboss.pnc.spi.repositorymanager.model.RepositoryConnectionInfo)4 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)3 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2