使用測試報告許可 - AWS CodeBuild

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用測試報告許可

本主題說明與測試報告相關的重要許可資訊。

建立測試報告的角色

若要測試執行報告,並更新專案以包含測試報告,您的 IAM 角色需要下列許可。這些權限包含在預先定義的 AWS 受管理策略中。如果您想要將測試報告新增至現有的建置專案,您必須自行新增這些許可。

  • CreateReportGroup

  • CreateReport

  • UpdateReport

  • BatchPutTestCases

若要執行程式碼涵蓋範圍報告,您的 IAM 角色也必須包含BatchPutCodeCoverages權限。

注意

BatchPutTestCasesCreateReportUpdateReport、和不BatchPutCodeCoverages是公開權限。您無法針對這些權限呼叫對應的 AWS CLI 命令或 SDK 方法。

為確保您擁有這些許可,您可以將以下政策附加到 IAM 角色:

{ "Effect": "Allow", "Resource": [ "*" ], "Action": [ "codebuild:CreateReportGroup", "codebuild:CreateReport", "codebuild:UpdateReport", "codebuild:BatchPutTestCases", "codebuild:BatchPutCodeCoverages" ] }

建議您將此政策限制為您必須使用的這些報告群組。在以下範例中,僅限具有政策中兩個 ARN 的報告群組才擁有許可:

{ "Effect": "Allow", "Resource": [ "arn:aws:codebuild:your-region:your-aws-account-id:report-group/report-group-name-1", "arn:aws:codebuild:your-region:your-aws-account-id:report-group/report-group-name-2" ], "Action": [ "codebuild:CreateReportGroup", "codebuild:CreateReport", "codebuild:UpdateReport", "codebuild:BatchPutTestCases", "codebuild:BatchPutCodeCoverages" ] }

在以下範例中,僅限在執行名為 my-project 之專案的建置時建立的報告群組才擁有許可:

{ "Effect": "Allow", "Resource": [ "arn:aws:codebuild:your-region:your-aws-account-id:report-group/my-project-*" ], "Action": [ "codebuild:CreateReportGroup", "codebuild:CreateReport", "codebuild:UpdateReport", "codebuild:BatchPutTestCases", "codebuild:BatchPutCodeCoverages" ] }
注意

專案中指定的 CodeBuild 服務角色用於上傳至 S3 儲存貯體的許可。

您可以指定下列測試報告 CodeBuild API 作業的權限:

  • BatchGetReportGroups

  • BatchGetReports

  • CreateReportGroup

  • DeleteReportGroup

  • DeleteReport

  • DescribeTestCases

  • ListReportGroups

  • ListReports

  • ListReportsForReportGroup

  • UpdateReportGroup

如需詳細資訊,請參閱 AWS CodeBuild 權限參考

測試報告許可範例

如需與測試報告相關的範例政策資訊,請參閱以下相關資訊: