Example usage for com.amazonaws.services.codebuild.model ListProjectsResult getProjects

List of usage examples for com.amazonaws.services.codebuild.model ListProjectsResult getProjects

Introduction

In this page you can find the example usage for com.amazonaws.services.codebuild.model ListProjectsResult getProjects.

Prototype


public java.util.List<String> getProjects() 

Source Link

Document

The list of build project names, with each build project name representing a single build project.

Usage

From source file:ProjectFactory.java

License:Open Source License

public String createProject(String projectName, String description, ProjectSource source,
        ProjectArtifacts artifacts, ProjectEnvironment environment, String serviceIAMRole, String timeout,
        String encryptionKey) throws Exception {

    ListProjectsRequest lpRequest;/*  w w  w. j av a 2  s.c o  m*/
    ListProjectsResult lpResult;

    List<String> projects = new ArrayList<String>();
    String nextToken = null;
    do {
        lpRequest = new ListProjectsRequest().withNextToken(nextToken);
        lpResult = cbClient.listProjects(lpRequest);
        nextToken = lpResult.getNextToken();
        projects.addAll(lpResult.getProjects());
    } while (nextToken != null);

    if (projects.contains(projectName)) {
        UpdateProjectResult upResult = cbClient.updateProject(
                new UpdateProjectRequest().withName(projectName).withDescription(description).withSource(source)
                        .withArtifacts(artifacts).withEnvironment(environment).withServiceRole(serviceIAMRole)
                        .withTimeoutInMinutes(Validation.parseInt(timeout)).withEncryptionKey(encryptionKey));

        return upResult.getProject().getName();
    } else {
        CreateProjectResult cpResult = cbClient.createProject(
                new CreateProjectRequest().withName(projectName).withDescription(description).withSource(source)
                        .withArtifacts(artifacts).withEnvironment(environment).withServiceRole(serviceIAMRole)
                        .withTimeoutInMinutes(Validation.parseInt(timeout)).withEncryptionKey(encryptionKey));

        return cpResult.getProject().getName();
    }
}