use of org.jboss.pnc.bpm.model.BuildExecutionConfigurationRest in project pnc by project-ncl.
the class BuildResultMapper method toDTO.
public BuildResultRest toDTO(BuildResult buildResult) {
CompletionStatus completionStatus = buildResult.getCompletionStatus();
ProcessException processException = buildResult.getProcessException().orElse(null);
String processLog = buildResult.getProcessLog();
BuildExecutionConfigurationRest buildExecutionConfiguration;
if (buildResult.getBuildExecutionConfiguration().isPresent()) {
BuildExecutionConfiguration bec = buildResult.getBuildExecutionConfiguration().get();
buildExecutionConfiguration = new BuildExecutionConfigurationRest(bec);
} else {
buildExecutionConfiguration = null;
}
BuildDriverResultRest buildDriverResult;
if (buildResult.getBuildDriverResult().isPresent()) {
BuildDriverResult result = buildResult.getBuildDriverResult().get();
buildDriverResult = new BuildDriverResultRest(result);
} else {
buildDriverResult = null;
}
RepositoryManagerResultRest repositoryManagerResult;
if (buildResult.getRepositoryManagerResult().isPresent()) {
RepositoryManagerResult result = buildResult.getRepositoryManagerResult().get();
repositoryManagerResult = repositoryManagerResultMapper.toDTO(result);
} else {
repositoryManagerResult = null;
}
EnvironmentDriverResult environmentDriverResult;
if (buildResult.getEnvironmentDriverResult().isPresent()) {
environmentDriverResult = buildResult.getEnvironmentDriverResult().get();
} else {
environmentDriverResult = null;
}
RepourResult repourResult = buildResult.getRepourResult().orElse(null);
return new BuildResultRest(completionStatus, processException, processLog, buildExecutionConfiguration, buildDriverResult, repositoryManagerResult, environmentDriverResult, repourResult);
}
use of org.jboss.pnc.bpm.model.BuildExecutionConfigurationRest in project pnc by project-ncl.
the class BuildTaskEndpointTest method shouldTriggerBuildExecution.
@Test
public void shouldTriggerBuildExecution() throws RemoteResourceException {
HttpPost request = new HttpPost(url + BASE_REST_PATH + "/build-tasks/execute-build");
request.addHeader(Credentials.USER.createAuthHeader(BasicHeader::new));
BuildExecutionConfiguration buildExecutionConfig = BuildExecutionConfiguration.build("1", "test-content-id", "1", "mvn clean install", "12", "jboss-modules", "scm-url", "f18de64523d5054395d82e24d4e28473a05a3880", "1.0.0.redhat-1", "origin-scm-url", false, "dummy-docker-image-id", "dummy.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(buildExecutionConfig);
List<NameValuePair> requestParameters = new ArrayList<>();
requestParameters.add(new BasicNameValuePair("buildExecutionConfiguration", buildExecutionConfigurationRest.toString()));
try {
request.setEntity(new UrlEncodedFormEntity(requestParameters));
} catch (UnsupportedEncodingException e) {
log.error("Cannot prepare request.", e);
Assert.fail("Cannot prepare request." + e.getMessage());
}
log.info("Executing request {} with parameters: {}", request.getRequestLine(), requestParameters);
int statusCode = -1;
try (CloseableHttpClient httpClient = HttpUtils.getPermissiveHttpClient()) {
try (CloseableHttpResponse response = httpClient.execute(request)) {
statusCode = response.getStatusLine().getStatusCode();
Assert.assertEquals("Received error response code. Response: " + printEntity(response), 200, statusCode);
}
} catch (IOException e) {
Assertions.fail("Cannot invoke remote endpoint.", e);
}
}
use of org.jboss.pnc.bpm.model.BuildExecutionConfigurationRest in project pnc by project-ncl.
the class BpmBuildTask method getBuildExecutionConfiguration.
private BuildExecutionConfigurationRest getBuildExecutionConfiguration(BuildTask buildTask) {
BuildConfigurationAudited buildConfigurationAudited = buildTask.getBuildConfigurationAudited();
String contentId = ContentIdentityManager.getBuildContentId(buildTask.getId());
BuildExecutionConfiguration buildExecutionConfiguration = BuildExecutionConfiguration.build(buildTask.getId(), contentId, buildTask.getUser().getId().toString(), buildConfigurationAudited.getBuildScript(), buildConfigurationAudited.getId().toString(), buildConfigurationAudited.getName(), // TODO update to use also other parts or Repository Configuration
buildConfigurationAudited.getRepositoryConfiguration().getInternalUrl(), buildConfigurationAudited.getScmRevision(), // SCM Tag is about to be set once it is created after the alignment phase
null, buildConfigurationAudited.getRepositoryConfiguration().getExternalUrl(), buildConfigurationAudited.getRepositoryConfiguration().isPreBuildSyncEnabled(), buildConfigurationAudited.getBuildEnvironment().getSystemImageId(), buildConfigurationAudited.getBuildEnvironment().getSystemImageRepositoryUrl(), buildConfigurationAudited.getBuildEnvironment().getSystemImageType(), buildConfigurationAudited.getBuildConfiguration().getBuildType(), buildTask.getBuildOptions().isKeepPodOnFailure(), buildConfigurationAudited.getGenericParameters(), buildTask.getBuildOptions().isTemporaryBuild(), TimeUtils.generateTimestamp(buildTask.getBuildOptions().isTimestampAlignment(), buildTask.getBuildSetTask().getStartTime()), buildConfigurationAudited.isBrewPullActive(), buildConfigurationAudited.getDefaultAlignmentParams(), buildTask.getBuildOptions().getAlignmentPreference());
return new BuildExecutionConfigurationRest(buildExecutionConfiguration);
}
use of org.jboss.pnc.bpm.model.BuildExecutionConfigurationRest 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());
}
use of org.jboss.pnc.bpm.model.BuildExecutionConfigurationRest 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));
}
Aggregations