Search in sources :

Example 61 with BuildConfiguration

use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.

the class DefaultBuildCoordinator method checkIfAnyBuildConfigurationNeedsARebuild.

private void checkIfAnyBuildConfigurationNeedsARebuild(BuildSetTask buildSetTask, BuildConfigurationSet buildConfigurationSet, boolean checkImplicitDependencies, boolean temporaryBuild, AlignmentPreference alignmentPreference) {
    Set<BuildConfiguration> buildConfigurations = buildConfigurationSet.getBuildConfigurations();
    int requiresRebuild = buildConfigurations.size();
    log.debug("There are {} configurations in a set {}.", requiresRebuild, buildConfigurationSet.getId());
    Set<Integer> processedDependenciesCache = new HashSet<>();
    for (BuildConfiguration buildConfiguration : buildConfigurations) {
        BuildConfigurationAudited buildConfigurationAudited = datastoreAdapter.getLatestBuildConfigurationAuditedInitializeBCDependencies(buildConfiguration.getId());
        if (!datastoreAdapter.requiresRebuild(buildConfigurationAudited, checkImplicitDependencies, temporaryBuild, alignmentPreference, processedDependenciesCache)) {
            requiresRebuild--;
        }
    }
    if (requiresRebuild == 0) {
        updateBuildSetTaskStatus(buildSetTask, BuildSetStatus.NO_REBUILD_REQUIRED, "All build configs were previously built");
    }
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) HashSet(java.util.HashSet)

Example 62 with BuildConfiguration

use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.

the class BuildTriggererImpl method doTriggerBuild.

private BuildSetTask doTriggerBuild(final int buildConfigId, OptionalInt buildConfigurationRevision, BuildOptions buildOptions) throws BuildConflictException, CoreException {
    BuildSetTask buildSetTask;
    if (buildConfigurationRevision.isPresent()) {
        final BuildConfigurationAudited buildConfigurationAudited = buildConfigurationAuditedRepository.queryById(new IdRev(buildConfigId, buildConfigurationRevision.getAsInt()));
        Preconditions.checkArgument(buildConfigurationAudited != null, "Can't find Build Configuration with id=" + buildConfigId + ", rev=" + buildConfigurationRevision.getAsInt());
        buildSetTask = buildCoordinator.build(hibernateLazyInitializer.initializeBuildConfigurationAuditedBeforeTriggeringIt(buildConfigurationAudited), user.currentUser(), buildOptions);
    } else {
        final BuildConfiguration buildConfiguration = buildConfigurationRepository.queryById(buildConfigId);
        Preconditions.checkArgument(buildConfiguration != null, "Can't find Build Configuration with id=" + buildConfigId);
        buildSetTask = buildCoordinator.build(hibernateLazyInitializer.initializeBuildConfigurationBeforeTriggeringIt(buildConfiguration), user.currentUser(), buildOptions);
    }
    logger.info("Started build of Build Configuration {}. Build Tasks: {}", buildConfigId, buildSetTask.getBuildTasks().stream().map(BuildTask::getId).collect(Collectors.joining()));
    return buildSetTask;
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) IdRev(org.jboss.pnc.model.IdRev)

Example 63 with BuildConfiguration

use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.

the class ProductVersionProviderImpl method store.

@Override
public ProductVersion store(ProductVersion restEntity) {
    validateBeforeSaving(restEntity);
    org.jboss.pnc.model.ProductVersion productVersionRestDb = mapper.toEntity(restEntity);
    Product product = productRepository.queryById(Integer.valueOf(restEntity.getProduct().getId()));
    productVersionRestDb.generateBrewTagPrefix(product.getAbbreviation(), restEntity.getVersion(), systemConfig.getBrewTagPattern());
    org.jboss.pnc.model.ProductVersion productVersion = repository.save(productVersionRestDb);
    for (BuildConfiguration bc : productVersionRestDb.getBuildConfigurations()) {
        bc.setProductVersion(productVersion);
    }
    repository.flushAndRefresh(productVersion);
    return mapper.toDTO(productVersion);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) Product(org.jboss.pnc.model.Product)

Example 64 with BuildConfiguration

use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.

the class GroupConfigurationProviderImpl method archive.

private void archive(String groupConfigurationId) throws DTOValidationException {
    ValidationBuilder.validateObject(WhenUpdating.class).validateAgainstRepository(repository, Integer.valueOf(groupConfigurationId), true);
    BuildConfigurationSet buildConfigurationSet = repository.queryById(Integer.valueOf(groupConfigurationId));
    buildConfigurationSet.setArchived(true);
    // if a build group is archived, unlink the build group from the build configurations is associated with
    for (BuildConfiguration bc : buildConfigurationSet.getBuildConfigurations()) {
        bc.removeBuildConfigurationSet(buildConfigurationSet);
        buildConfigurationRepository.save(bc);
        buildConfigurationSet.removeBuildConfiguration(bc);
    }
    repository.save(buildConfigurationSet);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) WhenUpdating(org.jboss.pnc.dto.validation.groups.WhenUpdating)

Example 65 with BuildConfiguration

use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.

the class GroupConfigurationProviderImpl method removeConfiguration.

@Override
public void removeConfiguration(String id, String configId) {
    BuildConfigurationSet buildConfigSet = repository.queryById(Integer.valueOf(id));
    BuildConfiguration buildConfig = buildConfigurationRepository.queryById(Integer.valueOf(configId));
    ValidationBuilder.validateObject(buildConfigSet, WhenUpdating.class).validateCondition(buildConfigSet != null, "No build configuration set exists with id: " + id).validateCondition(buildConfig != null, "No build configuration exists with id: " + configId);
    if (buildConfigSet.getBuildConfigurations().contains(buildConfig)) {
        buildConfigSet.removeBuildConfiguration(buildConfig);
        repository.save(buildConfigSet);
    }
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet)

Aggregations

BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)65 Test (org.junit.Test)23 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)11 HashSet (java.util.HashSet)10 BuildRecord (org.jboss.pnc.model.BuildRecord)9 Project (org.jboss.pnc.model.Project)9 BuildOptions (org.jboss.pnc.spi.BuildOptions)9 BuildResult (org.jboss.pnc.spi.BuildResult)9 Logger (org.slf4j.Logger)9 LoggerFactory (org.slf4j.LoggerFactory)9 List (java.util.List)8 Set (java.util.Set)8 Inject (javax.inject.Inject)8 ObjectWrapper (org.jboss.pnc.common.util.ObjectWrapper)8 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)8 BuildExecutionStatusChangedEvent (org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent)8 IdRev (org.jboss.pnc.model.IdRev)7 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)7 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)7 Collectors (java.util.stream.Collectors)5