- AWS Code Sample demonstrates how to obtain information about all repositories.

/** * Copyright, Inc. or its affiliates. All Rights Reserved. * * This file is licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. A copy of * the License is located at * * * * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * */ package com.example.commit; import; import; import; import; import; import java.util.List; public class ListRepositories { public static void main(String[] args) { Region region = Region.US_EAST_1; CodeCommitClient codeCommitClient = CodeCommitClient.builder() .region(region) .build(); listRepos(codeCommitClient); } public static void listRepos(CodeCommitClient codeCommitClient) { try { // Get all repositories ListRepositoriesResponse repResponse = codeCommitClient.listRepositories(); List<RepositoryNameIdPair> repoList = repResponse.repositories(); for (RepositoryNameIdPair repo: repoList) { System.out.println("The repository name is "+repo.repositoryName()); } } catch (CodeCommitException e) { System.err.println(e.getMessage()); System.exit(1); } } }

Sample Details

Service: AWS CodeCommit

Last tested: 2020-09-30

Author: AWS - scmacdon

Type: full-example