use of org.jboss.pnc.enums.BuildCategory in project pnc by project-ncl.
the class ArtifactProviderTest method testStore.
@Test
public void testStore() {
TargetRepository repo = TargetRepository.refBuilder().identifier("repo-id").repositoryPath("/repo/path").repositoryType(RepositoryType.MAVEN).build();
final String identifier = "foo:bar:0.0.1";
Artifact artifact = Artifact.builder().identifier(identifier).artifactQuality(ArtifactQuality.NEW).buildCategory(BuildCategory.STANDARD).build();
Artifact stored = provider.store(artifact);
assertThat(stored.getIdentifier()).isEqualTo(identifier);
assertThat(stored.getId()).isNotNull();
Mockito.verify(repository).save(ArgumentMatchers.argThat(a -> identifier.equals(a.getIdentifier())));
}
use of org.jboss.pnc.enums.BuildCategory in project pnc by project-ncl.
the class BuildConfigurationEndpointImpl method validate.
private void validate(BuildConfiguration buildConfiguration) {
if (buildConfiguration != null) {
Map<String, String> parameters = buildConfiguration.getParameters();
String buildCategoryKey = BuildConfigurationParameterKeys.BUILD_CATEGORY.name();
if (parameters != null && parameters.containsKey(buildCategoryKey)) {
String buildCategoryStr = parameters.get(buildCategoryKey);
try {
BuildCategory.valueOf(buildCategoryStr.toUpperCase());
} catch (Exception ex) {
List<String> categories = Stream.of(BuildCategory.values()).map(BuildCategory::name).collect(Collectors.toList());
throw new InvalidEntityException(buildCategoryKey + " value '" + buildCategoryStr + "' is invalid. Valid values are: " + String.join(", ", categories) + '.');
}
}
}
}
use of org.jboss.pnc.enums.BuildCategory in project pnc by project-ncl.
the class RepositoryManagerDriver method createBuildRepository.
/**
* Use the Indy client API to setup global and build-set level repos and groups, then setup the repo/group needed
* for this build. Calculate the URL to use for resolving artifacts using the Indy Folo API (Folo is an artifact
* activity-tracker). Return a new session ({@link IndyRepositorySession}) containing this information.
*
* @throws RepositoryManagerException In the event one or more repositories or groups can't be created to support
* the build (or product, or shared-releases).
*/
@Override
public RepositorySession createBuildRepository(BuildExecution buildExecution, String accessToken, String serviceAccountToken, RepositoryType repositoryType, Map<String, String> genericParameters, boolean brewPullActive) throws RepositoryManagerException {
Indy indy = init(accessToken);
Indy serviceAccountIndy = init(serviceAccountToken);
String packageType = getIndyPackageTypeKey(repositoryType);
String buildId = buildExecution.getBuildContentId();
try {
setupBuildRepos(buildExecution, packageType, serviceAccountIndy, genericParameters, brewPullActive);
} catch (IndyClientException e) {
logger.debug("Failed to setup repository or repository group for this build");
throw new RepositoryManagerException("Failed to setup repository or repository group for this build: %s", e, e.getMessage());
}
// since we're setting up a group/hosted repo per build, we can pin the tracking ID to the build repo ID.
String url;
String deployUrl;
try {
// manually initialize the tracking record, just in case (somehow) nothing gets downloaded/uploaded.
indy.module(IndyFoloAdminClientModule.class).initReport(buildId);
StoreKey groupKey = new StoreKey(packageType, StoreType.group, buildId);
url = indy.module(IndyFoloContentClientModule.class).trackingUrl(buildId, groupKey);
StoreKey hostedKey = new StoreKey(packageType, StoreType.hosted, buildId);
deployUrl = indy.module(IndyFoloContentClientModule.class).trackingUrl(buildId, hostedKey);
if (INDY_SIDECAR_ENABLED) {
logger.info("Indy sidecar feature enabled: replacing Indy host with Indy sidecar host");
try {
url = UrlUtils.replaceHostInUrl(url, INDY_SIDECAR_URL);
deployUrl = UrlUtils.replaceHostInUrl(deployUrl, INDY_SIDECAR_URL);
} catch (MalformedURLException e) {
throw new RuntimeException(String.format("Indy sidecar url ('%s') or Indy urls ('%s', '%s') are malformed!", INDY_SIDECAR_URL, url, deployUrl));
}
}
logger.info("Using '{}' for {} repository access in build: {}", url, packageType, buildId);
} catch (IndyClientException e) {
logger.debug("Failed to retrieve Indy client module for the artifact tracker");
throw new RepositoryManagerException("Failed to retrieve Indy client module for the artifact tracker: %s", e, e.getMessage());
}
boolean tempBuild = buildExecution.isTempBuild();
String buildPromotionTarget = tempBuild ? TEMP_BUILD_PROMOTION_TARGET : BUILD_PROMOTION_TARGET;
BuildCategory buildCategory = getBuildCategory(genericParameters);
ArtifactFilter artifactFilter = new ArtifactFilterImpl(ignoredPathPatternsPromotion, ignoredPathPatternsData, ignoredRepoPatterns);
return new IndyRepositorySession(indy, serviceAccountIndy, buildId, packageType, new IndyRepositoryConnectionInfo(url, deployUrl), artifactFilter, buildPromotionTarget, buildCategory, tempBuild);
}
use of org.jboss.pnc.enums.BuildCategory 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