Search in sources :

Example 1 with BuildConfiguration

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();
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) HashMap(java.util.HashMap)

Example 2 with BuildConfiguration

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();
    }
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Environment(org.jboss.pnc.dto.Environment) ProjectRef(org.jboss.pnc.dto.ProjectRef) SCMRepository(org.jboss.pnc.dto.SCMRepository)

Example 3 with BuildConfiguration

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;
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration)

Example 4 with BuildConfiguration

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();
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) SCMRepositoryClient(org.jboss.pnc.client.SCMRepositoryClient) ProductClient(org.jboss.pnc.client.ProductClient) EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) ProjectClient(org.jboss.pnc.client.ProjectClient) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) SCMRepository(org.jboss.pnc.dto.SCMRepository) BeforeClass(org.junit.BeforeClass)

Example 5 with BuildConfiguration

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");
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)90 Test (org.junit.Test)65 ContainerTest (org.jboss.pnc.test.category.ContainerTest)45 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)31 HashMap (java.util.HashMap)17 InSequence (org.jboss.arquillian.junit.InSequence)17 Build (org.jboss.pnc.dto.Build)13 GroupBuild (org.jboss.pnc.dto.GroupBuild)12 SCMRepository (org.jboss.pnc.dto.SCMRepository)10 Test (org.junit.jupiter.api.Test)10 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)9 Instant (java.time.Instant)8 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)7 BuildStatus (org.jboss.pnc.enums.BuildStatus)7 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 ArrayList (java.util.ArrayList)4 BuildConfigurationRevision (org.jboss.pnc.dto.BuildConfigurationRevision)4 HashSet (java.util.HashSet)3