本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 Amazon SDK或ListBuilds
一起使用 CLI
以下代码示例演示如何使用 ListBuilds
。
- C++
-
- SDK对于 C++
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整实例,了解如何进行设置和运行。 //! List the CodeBuild builds. /*! \param sortType: 'SortOrderType' type. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::CodeBuild::listBuilds(Aws::CodeBuild::Model::SortOrderType sortType, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::CodeBuild::CodeBuildClient codeBuildClient(clientConfiguration); Aws::CodeBuild::Model::ListBuildsRequest listBuildsRequest; listBuildsRequest.SetSortOrder(sortType); Aws::String nextToken; // Used for pagination. do { if (!nextToken.empty()) { listBuildsRequest.SetNextToken(nextToken); } Aws::CodeBuild::Model::ListBuildsOutcome listBuildsOutcome = codeBuildClient.ListBuilds( listBuildsRequest); if (listBuildsOutcome.IsSuccess()) { const Aws::Vector<Aws::String> &ids = listBuildsOutcome.GetResult().GetIds(); if (!ids.empty()) { std::cout << "Information about each build:" << std::endl; Aws::CodeBuild::Model::BatchGetBuildsRequest getBuildsRequest; getBuildsRequest.SetIds(listBuildsOutcome.GetResult().GetIds()); Aws::CodeBuild::Model::BatchGetBuildsOutcome getBuildsOutcome = codeBuildClient.BatchGetBuilds( getBuildsRequest); if (getBuildsOutcome.IsSuccess()) { const Aws::Vector<Aws::CodeBuild::Model::Build> &builds = getBuildsOutcome.GetResult().GetBuilds(); std::cout << builds.size() << " build(s) found." << std::endl; for (auto val: builds) { std::cout << val.GetId() << std::endl; } } else { std::cerr << "Error getting builds" << getBuildsOutcome.GetError().GetMessage() << std::endl; return false; } } else { std::cout << "No builds found." << std::endl; } // Get the next token for pagination. nextToken = listBuildsOutcome.GetResult().GetNextToken(); } else { std::cerr << "Error listing builds" << listBuildsOutcome.GetError().GetMessage() << std::endl; return false; } } while (!nextToken. empty() ); return true; }
-
有关API详细信息,请参阅 “Amazon SDK for C++ API参考 ListBuilds” 中的。
-
- CLI
-
- Amazon CLI
-
获取 Amazon CodeBuild 版本列表IDs。
以下
list-builds
示例获取按升 CodeBuild IDs序排序的列表。aws codebuild list-builds --sort-order
ASCENDING
输出包含一个
nextToken
值,该值表示还有更多可用的输出。{ "nextToken": "4AEA6u7J...The full token has been omitted for brevity...MzY2OA==", "ids": [ "codebuild-demo-project:815e755f-bade-4a7e-80f0-efe51EXAMPLE" "codebuild-demo-project:84a7f3d1-d40e-4956-b4cf-7a9d4EXAMPLE" ... The full list of build IDs has been omitted for brevity ... "codebuild-demo-project:931d0b72-bf6f-4040-a472-5c707EXAMPLE" ] }
再次运行此命令并提供上一个响应中的
nextToken
值作为参数,以获取输出的下一部分。重复此操作,直到您在响应中没有收到任何nextToken
值。aws codebuild list-builds --sort-order
ASCENDING
--next-token4AEA6u7J...The
full
token
has
been
omitted
for
brevity...MzY2OA==
输出的下一部分:
{ "ids": [ "codebuild-demo-project:49015049-21cf-4b50-9708-df115EXAMPLE", "codebuild-demo-project:543e7206-68a3-46d6-a4da-759abEXAMPLE", ... The full list of build IDs has been omitted for brevity ... "codebuild-demo-project:c282f198-4582-4b38-bdc0-26f96EXAMPLE" ] }
有关更多信息,请参阅《Amazon CodeBuild 用户指南》中的查看 Build IDs (Amazon CLI) 列表
-
有关API详细信息,请参阅Amazon CLI 命令参考ListBuilds
中的。
-
有关 Amazon SDK开发者指南和代码示例的完整列表,请参阅将此服务与 Amazon SDK。本主题还包括有关入门的信息以及有关先前SDK版本的详细信息。
CreateProject
ListProjects