use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class RemoteBuildTest method prepareBuildConfiguration.
public String prepareBuildConfiguration(String buildConfigurationName) throws RemoteResourceException {
Map<String, String> parameters = new HashMap<>();
parameters.put("CUSTOM_PME_PARAMETERS", "-Dmanipulation.disable=true");
String buildScript = "set +x\n" + "for i in {1..100}; do\n" + " echo $i \"- 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\"\n" + "done\n" + "echo \"Need to rest for a while ...\"\n" + "sleep 30";
BuildConfiguration buildConfiguration = getOrCreateBuildConfiguration(buildConfigurationName, buildScript, "master", parameters, "8", "9", "3");
return buildConfiguration.getId();
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class RemoteBuildTest method getOrCreateBuildConfiguration.
private BuildConfiguration getOrCreateBuildConfiguration(String buildConfigurationName, String buildScript, String scmRevision, Map<String, String> genericParameters, String projectId, String repositoryConfigurationId, String buildEnvironmentId) throws RemoteResourceException {
RemoteCollection<BuildConfiguration> existing = buildConfigurationRestClient.getAll(Optional.empty(), Optional.of("name==" + buildConfigurationName));
Iterator<BuildConfiguration> it = existing.iterator();
if (!it.hasNext()) {
ProjectRef project = ProjectRef.refBuilder().id(projectId).build();
SCMRepository repository = SCMRepository.builder().id(repositoryConfigurationId).build();
Environment environment = Environment.builder().id(buildEnvironmentId).build();
BuildConfiguration buildConfiguration = BuildConfiguration.builder().name(buildConfigurationName).project(project).scmRepository(repository).scmRevision(scmRevision).environment(environment).buildScript(buildScript).parameters(genericParameters).build();
BuildConfiguration created = buildConfigurationRestClient.createNew(buildConfiguration);
return created;
} else {
return it.next();
}
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class SecondLevelCacheStoreTest method createBuildConfigurationAndValidateResults.
private BuildConfiguration createBuildConfigurationAndValidateResults(String projectId, String environmentId, String repositoryConfigurationId, String name, String genericParameterValue1) throws ClientException {
BuildConfiguration buildConfiguration = BuildConfiguration.builder().project(ProjectRef.refBuilder().id(projectId).build()).environment(Environment.builder().id(environmentId).build()).scmRepository(SCMRepository.builder().id(repositoryConfigurationId).build()).name(name).parameters(Collections.singletonMap("KEY1", genericParameterValue1)).buildType(BuildType.MVN).build();
BuildConfiguration newBC = buildConfigurationClient.createNew(buildConfiguration);
return newBC;
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method prepareData.
@SuppressWarnings("unchecked")
@BeforeClass
public static void prepareData() throws Exception {
BuildConfigurationClient bcc = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
Iterator<BuildConfiguration> it = bcc.getAll().iterator();
configurationId = it.next().getId();
configuration2Id = it.next().getId();
configuration3Id = it.next().getId();
configuration4Id = it.next().getId();
ProductClient pdc = new ProductClient(RestClientConfiguration.asAnonymous());
productId = pdc.getAll().iterator().next().getId();
EnvironmentClient ec = new EnvironmentClient(RestClientConfiguration.asAnonymous());
environmentId = ec.getAll().iterator().next().getId();
ProjectClient pjc = new ProjectClient(RestClientConfiguration.asAnonymous());
projectId = pjc.getAll().iterator().next().getId();
SCMRepositoryClient scmrc = new SCMRepositoryClient(RestClientConfiguration.asAnonymous());
final Iterator<SCMRepository> scmrIt = scmrc.getAll(null, null).iterator();
repositoryConfigurationId = scmrIt.next().getId();
repositoryConfiguration2Id = scmrIt.next().getId();
}
use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method shouldRestoreBuildConfigurationRevision.
@Test
@InSequence(50)
public void shouldRestoreBuildConfigurationRevision() throws Exception {
// given
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
BuildConfiguration original = client.getSpecific(configurationId);
String description = original.getDescription();
Iterator<BuildConfigurationRevision> it = client.getRevisions(configurationId).iterator();
// given latest revision
BuildConfigurationRevision originalRev = it.next();
while (it.hasNext()) {
BuildConfigurationRevision candidate = it.next();
if (candidate.getRev() > originalRev.getRev()) {
originalRev = candidate;
}
}
// when
String newDescription = "shouldRestoreBuildConfigurationRevision Updated";
BuildConfiguration toUpdate = original.toBuilder().description(newDescription).build();
client.update(configurationId, toUpdate);
assertThat(toUpdate.getDescription()).isNotEqualTo(description);
// and when
BuildConfiguration restored = client.restoreRevision(configurationId, originalRev.getRev());
BuildConfiguration retrieved = client.getSpecific(configurationId);
// then
// we don't audit anymore the description, so it cannot be restored from a previous revision
assertThat(restored.getDescription()).isEqualTo(toUpdate.getDescription());
assertThat(restored).isEqualToIgnoringGivenFields(original, "description", "modificationTime", "modificationUser", "creationTime", "creationUser");
assertThat(retrieved).isEqualToIgnoringGivenFields(restored, "description", "modificationTime", "modificationUser", "creationTime", "creationUser");
}
Aggregations