use of org.jboss.pnc.spi.repositorymanager.RepositoryManager 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.spi.repositorymanager.RepositoryManager in project pnc by project-ncl.
the class IndyPromotionValidationTest method testIndyPromotionValidation.
@Test
public /**
* Test whose purpose is to provide a means for more or less easy debugging of indy validation errors. For it to
* work it needs a standalone Indy server, with a rule-set definition such as this: { "storeKeyPattern":
* "group:builds-untested", "ruleNames": [ "no-snapshots.groovy", "parsable-pom.groovy" ], "validationParameters":
* {} } Provide the base URL to this Indy server as a System parameter such as e.g.
* -DbaseUrl="http://127.0.0.1:8090"
*/
void testIndyPromotionValidation() {
String baseUrl = System.getProperty("baseUrl");
if (StringUtils.isBlank(baseUrl)) {
fail("No base URL has been specified");
}
RepositoryManager driver = null;
try {
driver = new RepositoryManagerDriver(new TestConfiguration(baseUrl), new BuildRecordRepositoryMock());
RepositorySession repositorySession = driver.createBuildRepository(new TestBuildExecution("test"), null, null, RepositoryType.MAVEN, Collections.emptyMap(), false);
CloseableHttpClient client = HttpClientBuilder.create().build();
String deployUrl = repositorySession.getConnectionInfo().getDeployUrl();
// Deploy several 'wrong' artifacts to get a composed error message back
String pathPom1 = "org/foo/invalid/1/invalid-1.pom";
String snapshotPom = "<?xml version=\"1.0\"?>\n<project><modelVersion>4.0.0</modelVersion><groupId>org.foo</groupId>" + "<artifactId>invalid</artifactId><version>1</version><dependencies>" + "<dependency><groupId>org.bar</groupId><artifactId>dep</artifactId>" + "<version>1.0-SNAPSHOT</version></dependency></dependencies></project>";
String url = UrlUtils.buildUrl(deployUrl, pathPom1);
put(client, url, snapshotPom);
String pathPom2 = "org/foo/invalid2/1/invalid2-1.pom";
String snapshotPom2 = "<?xml version=\"1.0\"?>\n<project><modelVersion>4.0.0</modelVersion><groupId>org.foo</groupId>" + "<artifactId>invalid2</artifactId><version>1</version><dependencies>" + "<dependency><groupId>org.bar</groupId><artifactId>dep</artifactId>" + "<version>1.0-SNAPSHOT</version></dependency></dependencies></project>";
url = UrlUtils.buildUrl(deployUrl, pathPom2);
put(client, url, snapshotPom2);
String pathPom3 = "org/foo/nonparseable/1/nonparseable.pom";
String nonparseablePom = "<?xml version=\"1.0\"?>\n<project><modelVersion>4.0.0</modelVersion><groupId>org.foo</groupId>" + "<artifactId>nonparseable</artifactId><version>1</version><dependencies>" + "<dependency><groupId>org.bar</groupId><artifactId>dep</artifactId>" + "<version>1.0</version></dependency></dependencies></project>";
url = UrlUtils.buildUrl(deployUrl, pathPom3);
put(client, url, nonparseablePom);
RepositoryManagerResult repositoryManagerResult = repositorySession.extractBuildArtifacts(true);
// Just a dummy check, the point is really to be able to debug this
assertSame(CompletionStatus.FAILED, repositoryManagerResult.getCompletionStatus());
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations