Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Use ListProjects with an AWS SDK or CLI

Focus mode
Use ListProjects with an AWS SDK or CLI - AWS CodeBuild

The following code examples show how to use ListProjects.

C++
SDK for C++
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

//! List the CodeBuild projects. /*! \param sortType: 'SortOrderType' type. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::CodeBuild::listProjects(Aws::CodeBuild::Model::SortOrderType sortType, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::CodeBuild::CodeBuildClient codeBuildClient(clientConfiguration); Aws::CodeBuild::Model::ListProjectsRequest listProjectsRequest; listProjectsRequest.SetSortOrder(sortType); Aws::String nextToken; // Next token for pagination. Aws::Vector<Aws::String> allProjects; do { if (!nextToken.empty()) { listProjectsRequest.SetNextToken(nextToken); } Aws::CodeBuild::Model::ListProjectsOutcome outcome = codeBuildClient.ListProjects( listProjectsRequest); if (outcome.IsSuccess()) { const Aws::Vector<Aws::String> &projects = outcome.GetResult().GetProjects(); allProjects.insert(allProjects.end(), projects.begin(), projects.end()); nextToken = outcome.GetResult().GetNextToken(); } else { std::cerr << "Error listing projects" << outcome.GetError().GetMessage() << std::endl; } } while (!nextToken.empty()); std::cout << allProjects.size() << " project(s) found." << std::endl; for (auto project: allProjects) { std::cout << project << std::endl; } return true; }
  • For API details, see ListProjects in AWS SDK for C++ API Reference.

CLI
AWS CLI

To get a list of AWS CodeBuild build project names.

The following list-projects example gets a list of CodeBuild build projects sorted by name in ascending order.

aws codebuild list-projects --sort-by NAME --sort-order ASCENDING

The output includes a nextToken value which indicates that there is more output available.

{ "nextToken": "Ci33ACF6...The full token has been omitted for brevity...U+AkMx8=", "projects": [ "codebuild-demo-project", "codebuild-demo-project2", ... The full list of build project names has been omitted for brevity ... "codebuild-demo-project99" ] }

Run this command again and provide the nextToken value from the previous response as a parameter to get the next part of the output. Repeat until you don't receive a nextToken value in the response.

aws codebuild list-projects --sort-by NAME --sort-order ASCENDING --next-token Ci33ACF6...The full token has been omitted for brevity...U+AkMx8= { "projects": [ "codebuild-demo-project100", "codebuild-demo-project101", ... The full list of build project names has been omitted for brevity ... "codebuild-demo-project122" ] }

For more information, see View a List of Build Project Names (AWS CLI) in the AWS CodeBuild User Guide.

  • For API details, see ListProjects in AWS CLI Command Reference.

SDK for C++
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

//! List the CodeBuild projects. /*! \param sortType: 'SortOrderType' type. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::CodeBuild::listProjects(Aws::CodeBuild::Model::SortOrderType sortType, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::CodeBuild::CodeBuildClient codeBuildClient(clientConfiguration); Aws::CodeBuild::Model::ListProjectsRequest listProjectsRequest; listProjectsRequest.SetSortOrder(sortType); Aws::String nextToken; // Next token for pagination. Aws::Vector<Aws::String> allProjects; do { if (!nextToken.empty()) { listProjectsRequest.SetNextToken(nextToken); } Aws::CodeBuild::Model::ListProjectsOutcome outcome = codeBuildClient.ListProjects( listProjectsRequest); if (outcome.IsSuccess()) { const Aws::Vector<Aws::String> &projects = outcome.GetResult().GetProjects(); allProjects.insert(allProjects.end(), projects.begin(), projects.end()); nextToken = outcome.GetResult().GetNextToken(); } else { std::cerr << "Error listing projects" << outcome.GetError().GetMessage() << std::endl; } } while (!nextToken.empty()); std::cout << allProjects.size() << " project(s) found." << std::endl; for (auto project: allProjects) { std::cout << project << std::endl; } return true; }
  • For API details, see ListProjects in AWS SDK for C++ API Reference.

For a complete list of AWS SDK developer guides and code examples, see Using this service with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.