Example usage for com.amazonaws.services.codebuild.model UpdateProjectResult getProject

List of usage examples for com.amazonaws.services.codebuild.model UpdateProjectResult getProject

Introduction

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

Prototype


public Project getProject() 

Source Link

Document

Information about the build project that was changed.

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;//from ww w. j a  va2s . co  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();
    }
}