Search in sources :

Example 21 with BuildExecutionConfiguration

use of org.jboss.pnc.spi.executor.BuildExecutionConfiguration in project pnc by project-ncl.

the class BuildExecutionConfigurationTest method serializeAndDeserializeBuildResult.

@Test
public void serializeAndDeserializeBuildResult() throws IOException, BuildDriverException {
    BuildExecutionConfiguration buildExecutionConfiguration = BuildExecutionConfiguration.build("1", "condent-id", "1", "mvn clean install", "configuration name", "12", "https://pathToRepo.git", "f18de64523d5054395d82e24d4e28473a05a3880", "1.0.0.Final-redhat-00001", "https://pathToOriginRepo.git", false, "abcd1234", "image.repo.url/repo", SystemImageType.DOCKER_IMAGE, BuildType.MVN, false, null, new HashMap<>(), false, null, false, "-DdependencySource=REST -DrepoRemovalBackup=repositories-backup.xml -DversionSuffixStrip= -DreportNonAligned=true", AlignmentPreference.PREFER_PERSISTENT);
    BuildExecutionConfigurationRest buildExecutionConfigurationREST = new BuildExecutionConfigurationRest(buildExecutionConfiguration);
    String buildExecutionConfigurationJson = buildExecutionConfigurationREST.toString();
    log.debug("Json : {}", buildExecutionConfigurationJson);
    BuildExecutionConfigurationRest buildExecutionConfigurationRestFromJson = JsonOutputConverterMapper.readValue(buildExecutionConfigurationJson, BuildExecutionConfigurationRest.class);
    BuildExecutionConfiguration buildExecutionConfigurationFromJson = buildExecutionConfigurationRestFromJson.toBuildExecutionConfiguration();
    String message = "Deserialized object does not match the original.";
    Assert.assertEquals(message, buildExecutionConfiguration.getId(), buildExecutionConfigurationFromJson.getId());
    Assert.assertEquals(message, buildExecutionConfiguration.getBuildScript(), buildExecutionConfigurationFromJson.getBuildScript());
    Assert.assertEquals(message, buildExecutionConfiguration.getName(), buildExecutionConfigurationFromJson.getName());
    Assert.assertEquals(message, buildExecutionConfiguration.getScmRepoURL(), buildExecutionConfigurationFromJson.getScmRepoURL());
    Assert.assertEquals(message, buildExecutionConfiguration.getScmRevision(), buildExecutionConfigurationFromJson.getScmRevision());
    Assert.assertEquals(message, buildExecutionConfiguration.getScmTag(), buildExecutionConfigurationFromJson.getScmTag());
    Assert.assertEquals(message, buildExecutionConfiguration.getOriginRepoURL(), buildExecutionConfigurationFromJson.getOriginRepoURL());
    Assert.assertEquals(message, buildExecutionConfiguration.isPreBuildSyncEnabled(), buildExecutionConfigurationFromJson.isPreBuildSyncEnabled());
    Assert.assertEquals(message, buildExecutionConfiguration.getUserId(), buildExecutionConfigurationFromJson.getUserId());
}
Also used : BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) BuildExecutionConfigurationRest(org.jboss.pnc.bpm.model.BuildExecutionConfigurationRest) Test(org.junit.Test)

Example 22 with BuildExecutionConfiguration

use of org.jboss.pnc.spi.executor.BuildExecutionConfiguration in project pnc by project-ncl.

the class ComponentBuildParametersSerialization method shouldSerializeParameters.

@Test
public void shouldSerializeParameters() throws JsonProcessingException {
    BuildExecutionConfiguration buildExecutionConfiguration = BuildExecutionConfigurationMock.mock();
    BuildExecutionConfigurationRest buildExecutionConfigurationRest = new BuildExecutionConfigurationRest(buildExecutionConfiguration);
    ComponentBuildParameters processParameters = new ComponentBuildParameters("http://pncBaseUrl", "http://aproxBaseUrl", "http://repourBaseUrl", "http://daBaseUrl", false, true, buildExecutionConfigurationRest);
    String string = MAPPER.writeValueAsString(processParameters);
    log.debug("Serialized: {}", string);
    Assert.assertTrue(string.contains(BuildExecutionConfigurationMock.DEFAULT_SYSTEM_IMAGE_ID));
}
Also used : ComponentBuildParameters(org.jboss.pnc.bpm.model.ComponentBuildParameters) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) BuildExecutionConfigurationRest(org.jboss.pnc.bpm.model.BuildExecutionConfigurationRest) Test(org.junit.Test)

Example 23 with BuildExecutionConfiguration

use of org.jboss.pnc.spi.executor.BuildExecutionConfiguration in project pnc by project-ncl.

the class BuildResultMapper method toEntity.

public BuildResult toEntity(BuildResultRest buildResultRest) {
    RepositoryManagerResult repositoryManagerResult = null;
    if (buildResultRest.getRepositoryManagerResult() != null) {
        repositoryManagerResult = repositoryManagerResultMapper.toEntity(buildResultRest.getRepositoryManagerResult());
    }
    BuildExecutionConfiguration bec = null;
    if (buildResultRest.getBuildExecutionConfiguration() != null) {
        bec = buildResultRest.getBuildExecutionConfiguration().toBuildExecutionConfiguration();
    }
    return new BuildResult(buildResultRest.getCompletionStatus(), ofNullable(buildResultRest.getProcessException()), buildResultRest.getProcessLog(), ofNullable(bec), ofNullable(buildResultRest.getBuildDriverResult()), ofNullable(repositoryManagerResult), ofNullable(buildResultRest.getEnvironmentDriverResult()), ofNullable(buildResultRest.getRepourResult()));
}
Also used : BuildResult(org.jboss.pnc.spi.BuildResult) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult)

Example 24 with BuildExecutionConfiguration

use of org.jboss.pnc.spi.executor.BuildExecutionConfiguration in project pnc by project-ncl.

the class BuildExecutorTriggerer method executeBuild.

public BuildExecutionSession executeBuild(BuildExecutionConfiguration buildExecutionConfig, String callbackUrl, String accessToken) throws CoreException, ExecutorException {
    Consumer<BuildExecutionStatusChangedEvent> onExecutionStatusChange = (statusChangedEvent) -> {
        log.debug("Received BuildExecutionStatusChangedEvent: " + statusChangedEvent);
        if (statusChangedEvent.isFinal() && callbackUrl != null && !callbackUrl.isEmpty()) {
            statusChangedEvent.getBuildResult().ifPresent((buildResult) -> bpmNotifier.sendBuildExecutionCompleted(callbackUrl, buildResult, accessToken));
        }
    };
    BuildExecutionSession buildExecutionSession = buildExecutor.startBuilding(buildExecutionConfig, onExecutionStatusChange, accessToken);
    return buildExecutionSession;
}
Also used : Logger(org.slf4j.Logger) TaskStatusUpdateEvent(org.jboss.pnc.buildagent.api.TaskStatusUpdateEvent) BuildTaskContext(org.jboss.pnc.common.logging.BuildTaskContext) ExpiresDate(org.jboss.pnc.common.Date.ExpiresDate) BpmNotifier(org.jboss.pnc.bpm.notification.BpmNotifier) LoggerFactory(org.slf4j.LoggerFactory) BuildExecutor(org.jboss.pnc.spi.executor.BuildExecutor) Inject(javax.inject.Inject) Consumer(java.util.function.Consumer) CoreException(org.jboss.pnc.spi.exception.CoreException) Optional(java.util.Optional) BuildExecutionStatusChangedEvent(org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent) ApplicationScoped(javax.enterprise.context.ApplicationScoped) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) ExecutorException(org.jboss.pnc.spi.executor.exceptions.ExecutorException) SystemConfig(org.jboss.pnc.common.json.moduleconfig.SystemConfig) BuildExecutionSession(org.jboss.pnc.spi.executor.BuildExecutionSession) BuildExecutionSession(org.jboss.pnc.spi.executor.BuildExecutionSession) BuildExecutionStatusChangedEvent(org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent)

Aggregations

BuildExecutionConfiguration (org.jboss.pnc.spi.executor.BuildExecutionConfiguration)24 Consumer (java.util.function.Consumer)11 Logger (org.slf4j.Logger)11 LoggerFactory (org.slf4j.LoggerFactory)11 Test (org.junit.Test)10 BuildExecutionSession (org.jboss.pnc.spi.executor.BuildExecutionSession)9 SystemConfig (org.jboss.pnc.common.json.moduleconfig.SystemConfig)7 BuildResult (org.jboss.pnc.spi.BuildResult)7 ExecutorException (org.jboss.pnc.spi.executor.exceptions.ExecutorException)7 RepositoryManagerResult (org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult)7 ConfigurationParseException (org.jboss.pnc.common.json.ConfigurationParseException)6 BuildDriverResult (org.jboss.pnc.spi.builddriver.BuildDriverResult)6 CompletedBuild (org.jboss.pnc.spi.builddriver.CompletedBuild)6 RunningBuild (org.jboss.pnc.spi.builddriver.RunningBuild)6 RunningEnvironment (org.jboss.pnc.spi.environment.RunningEnvironment)6 IOException (java.io.IOException)5 BuildExecutionStatusChangedEvent (org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent)5 Inject (javax.inject.Inject)4 TaskStatusUpdateEvent (org.jboss.pnc.buildagent.api.TaskStatusUpdateEvent)4 BuildExecutionStatus (org.jboss.pnc.enums.BuildExecutionStatus)4