文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用 的 CodeBuild 範例 AWS CLI
下列程式碼範例示範如何使用 AWS Command Line Interface with CodeBuild 來執行動作和實作常見案例。
Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然 動作會示範如何呼叫個別服務函數,但您可以在其相關案例中查看內容中的動作。
每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。
主題
動作
下列程式碼範例示範如何使用 batch-delete-builds
。
- AWS CLI
-
刪除 in AWS CodeBuild 中的組建。
下列
batch-delete-builds
範例會刪除具有指定 CodeBuild 的建置 inIDs。aws codebuild batch-delete-builds --ids
my-build-project-one:a1b2c3d4-5678-9012-abcd-11111EXAMPLE
my-build-project-two:a1b2c3d4-5678-9012-abcd-22222EXAMPLE
輸出:
{ "buildsNotDeleted": [ { "id": "arn:aws:codebuild:us-west-2:123456789012:build/my-build-project-one:a1b2c3d4-5678-9012-abcd-11111EXAMPLE", "statusCode": "BUILD_IN_PROGRESS" } ], "buildsDeleted": [ "arn:aws:codebuild:us-west-2:123456789012:build/my-build-project-two:a1b2c3d4-5678-9012-abcd-22222EXAMPLE" ] }
如需詳細資訊,請參閱 AWS CLI 使用者指南中的刪除建置 (Word)。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 BatchDeleteBuilds
。
-
下列程式碼範例示範如何使用 batch-get-build-batches
。
- AWS CLI
-
檢視 in AWS CodeBuild 中建置的詳細資訊。
下列
batch-get-build-batches
範例取得使用指定 CodeBuild 建置 inIDs 批次的相關資訊。aws codebuild batch-get-build-batches \ --ids
codebuild-demo-project:e9c4f4df-3f43-41d2-ab3a-60fe2EXAMPLE
輸出:
{ "buildBatches": [ { "id": "codebuild-demo-project:e9c4f4df-3f43-41d2-ab3a-60fe2EXAMPLE", "arn": "arn:aws:codebuild:us-west-2:123456789012:build-batch/codebuild-demo-project:e9c4f4df-3f43-41d2-ab3a-60fe2EXAMPLE", "startTime": "2020-11-03T21:52:20.775000+00:00", "endTime": "2020-11-03T21:56:59.784000+00:00", "currentPhase": "SUCCEEDED", "buildBatchStatus": "SUCCEEDED", "resolvedSourceVersion": "0a6546f68309560d08a310daac92314c4d378f6b", "projectName": "codebuild-demo-project", "phases": [ { "phaseType": "SUBMITTED", "phaseStatus": "SUCCEEDED", "startTime": "2020-11-03T21:52:20.775000+00:00", "endTime": "2020-11-03T21:52:20.976000+00:00", "durationInSeconds": 0 }, { "phaseType": "DOWNLOAD_BATCHSPEC", "phaseStatus": "SUCCEEDED", "startTime": "2020-11-03T21:52:20.976000+00:00", "endTime": "2020-11-03T21:52:57.401000+00:00", "durationInSeconds": 36 }, { "phaseType": "IN_PROGRESS", "phaseStatus": "SUCCEEDED", "startTime": "2020-11-03T21:52:57.401000+00:00", "endTime": "2020-11-03T21:56:59.751000+00:00", "durationInSeconds": 242 }, { "phaseType": "COMBINE_ARTIFACTS", "phaseStatus": "SUCCEEDED", "startTime": "2020-11-03T21:56:59.751000+00:00", "endTime": "2020-11-03T21:56:59.784000+00:00", "durationInSeconds": 0 }, { "phaseType": "SUCCEEDED", "startTime": "2020-11-03T21:56:59.784000+00:00" } ], "source": { "type": "GITHUB", "location": "https://github.com/my-repo/codebuild-demo-project.git", "gitCloneDepth": 1, "gitSubmodulesConfig": { "fetchSubmodules": false }, "reportBuildStatus": false, "insecureSsl": false }, "secondarySources": [], "secondarySourceVersions": [], "artifacts": { "location": "" }, "secondaryArtifacts": [], "cache": { "type": "NO_CACHE" }, "environment": { "type": "LINUX_CONTAINER", "image": "aws/codebuild/amazonlinux2-x86_64-standard:3.0", "computeType": "BUILD_GENERAL1_SMALL", "environmentVariables": [], "privilegedMode": false, "imagePullCredentialsType": "CODEBUILD" }, "logConfig": { "cloudWatchLogs": { "status": "ENABLED" }, "s3Logs": { "status": "DISABLED", "encryptionDisabled": false } }, "buildTimeoutInMinutes": 60, "queuedTimeoutInMinutes": 480, "complete": true, "initiator": "Strohm", "encryptionKey": "arn:aws:kms:us-west-2:123456789012:alias/aws/s3", "buildBatchNumber": 6, "buildBatchConfig": { "serviceRole": "arn:aws:iam::123456789012:role/service-role/codebuild-demo-project", "restrictions": { "maximumBuildsAllowed": 100 }, "timeoutInMins": 480 }, "buildGroups": [ { "identifier": "DOWNLOAD_SOURCE", "ignoreFailure": false, "currentBuildSummary": { "arn": "arn:aws:codebuild:us-west-2:123456789012:build/codebuild-demo-project:379737d8-bc35-48ec-97fd-776d27545315", "requestedOn": "2020-11-03T21:52:21.394000+00:00", "buildStatus": "SUCCEEDED", "primaryArtifact": { "type": "no_artifacts", "identifier": "DOWNLOAD_SOURCE" }, "secondaryArtifacts": [] } }, { "identifier": "linux_small", "dependsOn": [], "ignoreFailure": false, "currentBuildSummary": { "arn": "arn:aws:codebuild:us-west-2:123456789012:build/codebuild-demo-project:dd785171-ed84-4bb6-8ede-ceeb86e54bdb", "requestedOn": "2020-11-03T21:52:57.604000+00:00", "buildStatus": "SUCCEEDED", "primaryArtifact": { "type": "no_artifacts", "identifier": "linux_small" }, "secondaryArtifacts": [] } }, { "identifier": "linux_medium", "dependsOn": [ "linux_small" ], "ignoreFailure": false, "currentBuildSummary": { "arn": "arn:aws:codebuild:us-west-2:123456789012:build/codebuild-demo-project:97cf7bd4-5313-4786-8243-4aef350a1267", "requestedOn": "2020-11-03T21:54:18.474000+00:00", "buildStatus": "SUCCEEDED", "primaryArtifact": { "type": "no_artifacts", "identifier": "linux_medium" }, "secondaryArtifacts": [] } }, { "identifier": "linux_large", "dependsOn": [ "linux_medium" ], "ignoreFailure": false, "currentBuildSummary": { "arn": "arn:aws:codebuild:us-west-2:123456789012:build/codebuild-demo-project:60a194cd-0d03-4337-9db1-d41476a17d27", "requestedOn": "2020-11-03T21:55:39.203000+00:00", "buildStatus": "SUCCEEDED", "primaryArtifact": { "type": "no_artifacts", "identifier": "linux_large" }, "secondaryArtifacts": [] } } ] } ], "buildBatchesNotFound": [] }
如需詳細資訊,請參閱 AWS CodeBuild AWS 使用者指南中的批次建置 inCodeBuild <latest/userguide/batchhttps://docs.aws.amazon.com/codebuild/-build.html>)__。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 BatchGetBuildBatches
。
-
下列程式碼範例示範如何使用 batch-get-builds
。
- AWS CLI
-
檢視 in AWS CodeBuild 中建置的詳細資訊。
下列
batch-get-builds
範例取得具有指定 CodeBuild 的 inWord 建置相關資訊IDs。aws codebuild batch-get-builds --ids
codebuild-demo-project:e9c4f4df-3f43-41d2-ab3a-60fe2EXAMPLE
codebuild-demo-project:815e755f-bade-4a7e-80f0-efe51EXAMPLE
輸出:
{ "buildsNotFound": [], "builds": [ { "artifacts": { "md5sum": "0e95edf915048a0c22efe6d139fff837", "location": "arn:aws:s3:::codepipeline-us-west-2-820783811474/CodeBuild-Python-Pip/BuildArtif/6DJsqQa", "encryptionDisabled": false, "sha256sum": "cfa0df33a090966a737f64ae4fe498969fdc842a0c9aec540bf93c37ac0d05a2" }, "logs": { "cloudWatchLogs": { "status": "ENABLED" }, "s3Logs": { "status": "DISABLED" }, "streamName": "46472baf-8f6b-43c2-9255-b3b963af2732", "groupName": "/aws/codebuild/codebuild-demo-project", "deepLink": "https://console.aws.amazon.com/cloudwatch/home?region=us-west-2#logEvent:group=/aws/codebuild/codebuild-demo-project;stream=46472baf-8f6b-43c2-9255-b3b963af2732" }, "timeoutInMinutes": 60, "environment": { "privilegedMode": false, "computeType": "BUILD_GENERAL1_MEDIUM", "image": "aws/codebuild/windows-base:1.0", "environmentVariables": [], "type": "WINDOWS_CONTAINER" }, "projectName": "codebuild-demo-project", "buildComplete": true, "source": { "gitCloneDepth": 1, "insecureSsl": false, "type": "CODEPIPELINE" }, "buildStatus": "SUCCEEDED", "secondaryArtifacts": [], "phases": [ { "durationInSeconds": 0, "startTime": 1548717462.122, "phaseType": "SUBMITTED", "endTime": 1548717462.484, "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 0, "startTime": 1548717462.484, "phaseType": "QUEUED", "endTime": 1548717462.775, "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 34, "endTime": 1548717496.909, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548717462.775, "phaseType": "PROVISIONING", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 15, "endTime": 1548717512.555, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548717496.909, "phaseType": "DOWNLOAD_SOURCE", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 0, "endTime": 1548717512.734, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548717512.555, "phaseType": "INSTALL", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 0, "endTime": 1548717512.924, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548717512.734, "phaseType": "PRE_BUILD", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 9, "endTime": 1548717522.254, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548717512.924, "phaseType": "BUILD", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 3, "endTime": 1548717525.498, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548717522.254, "phaseType": "POST_BUILD", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 9, "endTime": 1548717534.646, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548717525.498, "phaseType": "UPLOAD_ARTIFACTS", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 2, "endTime": 1548717536.846, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548717534.646, "phaseType": "FINALIZING", "phaseStatus": "SUCCEEDED" }, { "startTime": 1548717536.846, "phaseType": "COMPLETED" } ], "startTime": 1548717462.122, "encryptionKey": "arn:aws:kms:us-west-2:123456789012:alias/aws/s3", "initiator": "codepipeline/CodeBuild-Pipeline", "secondarySources": [], "serviceRole": "arn:aws:iam::123456789012:role/service-role/my-codebuild-service-role", "currentPhase": "COMPLETED", "id": "codebuild-demo-project:e9c4f4df-3f43-41d2-ab3a-60fe2EXAMPLE", "cache": { "type": "NO_CACHE" }, "sourceVersion": "arn:aws:s3:::codepipeline-us-west-2-820783811474/CodeBuild-Python-Pip/SourceArti/1TspnN3.zip", "endTime": 1548717536.846, "arn": "arn:aws:codebuild:us-west-2:123456789012:build/codebuild-demo-project:e9c4f4df-3f43-41d2-ab3a-60fe2EXAMPLE", "queuedTimeoutInMinutes": 480, "resolvedSourceVersion": "f2194c1757bbdcb0f8f229254a4b3c8b27d43e0b" }, { "artifacts": { "md5sum": "", "overrideArtifactName": false, "location": "arn:aws:s3:::my-artifacts/codebuild-demo-project", "encryptionDisabled": false, "sha256sum": "" }, "logs": { "cloudWatchLogs": { "status": "ENABLED" }, "s3Logs": { "status": "DISABLED" }, "streamName": "4dea3ca4-20ec-4898-b22a-a9eb9292775d", "groupName": "/aws/codebuild/codebuild-demo-project", "deepLink": "https://console.aws.amazon.com/cloudwatch/home?region=us-west-2#logEvent:group=/aws/codebuild/codebuild-demo-project;stream=4dea3ca4-20ec-4898-b22a-a9eb9292775d" }, "timeoutInMinutes": 60, "environment": { "privilegedMode": false, "computeType": "BUILD_GENERAL1_MEDIUM", "image": "aws/codebuild/windows-base:1.0", "environmentVariables": [], "type": "WINDOWS_CONTAINER" }, "projectName": "codebuild-demo-project", "buildComplete": true, "source": { "gitCloneDepth": 1, "location": "https://github.com/my-repo/codebuild-demo-project.git", "insecureSsl": false, "reportBuildStatus": false, "type": "GITHUB" }, "buildStatus": "SUCCEEDED", "secondaryArtifacts": [], "phases": [ { "durationInSeconds": 0, "startTime": 1548716241.89, "phaseType": "SUBMITTED", "endTime": 1548716242.241, "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 0, "startTime": 1548716242.241, "phaseType": "QUEUED", "endTime": 1548716242.536, "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 33, "endTime": 1548716276.171, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548716242.536, "phaseType": "PROVISIONING", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 15, "endTime": 1548716291.809, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548716276.171, "phaseType": "DOWNLOAD_SOURCE", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 0, "endTime": 1548716291.993, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548716291.809, "phaseType": "INSTALL", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 0, "endTime": 1548716292.191, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548716291.993, "phaseType": "PRE_BUILD", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 9, "endTime": 1548716301.622, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548716292.191, "phaseType": "BUILD", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 3, "endTime": 1548716304.783, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548716301.622, "phaseType": "POST_BUILD", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 8, "endTime": 1548716313.775, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548716304.783, "phaseType": "UPLOAD_ARTIFACTS", "phaseStatus": "SUCCEEDED" }, { "durationInSeconds": 2, "endTime": 1548716315.935, "contexts": [ { "statusCode": "", "message": "" } ], "startTime": 1548716313.775, "phaseType": "FINALIZING", "phaseStatus": "SUCCEEDED" }, { "startTime": 1548716315.935, "phaseType": "COMPLETED" } ], "startTime": 1548716241.89, "secondarySourceVersions": [], "initiator": "my-codebuild-project", "arn": "arn:aws:codebuild:us-west-2:123456789012:build/codebuild-demo-project:815e755f-bade-4a7e-80f0-efe51EXAMPLE", "encryptionKey": "arn:aws:kms:us-west-2:123456789012:alias/aws/s3", "serviceRole": "arn:aws:iam::123456789012:role/service-role/my-codebuild-service-role", "currentPhase": "COMPLETED", "id": "codebuild-demo-project:815e755f-bade-4a7e-80f0-efe51EXAMPLE", "cache": { "type": "NO_CACHE" }, "endTime": 1548716315.935, "secondarySources": [], "queuedTimeoutInMinutes": 480, "resolvedSourceVersion": "f2194c1757bbdcb0f8f229254a4b3c8b27d43e0b" } ] }
如需詳細資訊,請參閱 AWS CLI 使用者指南中的檢視建置詳細資訊 (Word)。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 BatchGetBuilds
。
-
下列程式碼範例示範如何使用 batch-get-projects
。
- AWS CLI
-
取得 AWS CodeBuild 組建專案名稱的清單。
下列
batch-get-projects
範例會取得名稱指定的 CodeBuild 組建專案清單。aws codebuild batch-get-projects --names
codebuild-demo-project
codebuild-demo-project2
my-other-demo-project
在下列輸出中,
projectsNotFound
陣列會列出指定但未找到的任何建置專案名稱。projects
陣列會列出每個找到資訊的組建專案詳細資訊。{ "projectsNotFound": [], "projects": [ { "encryptionKey": "arn:aws:kms:us-west-2:123456789012:alias/aws/s3", "name": "codebuild-demo-project2", "queuedTimeoutInMinutes": 480, "timeoutInMinutes": 60, "source": { "buildspec": "version: 0.2\n\n#env:\n #variables:\n # key: \"value\"\n # key: \"value\"\n #parameter-store:\n # key: \"value\"\n # key:\"value\"\n\nphases:\n #install:\n #commands:\n # - command\n # - command\n #pre_build:\n #commands:\n # - command\n # - command\n build:\n commands:\n # - command\n # - command\n #post_build:\n #commands:\n # - command\n # - command\n#artifacts:\n #files:\n # - location\n # - location\n #name: $(date +%Y-%m-%d)\n #discard-paths: yes\n #base-directory: location\n#cache:\n #paths:\n # - paths", "type": "NO_SOURCE", "insecureSsl": false, "gitCloneDepth": 1 }, "artifacts": { "type": "NO_ARTIFACTS" }, "badge": { "badgeEnabled": false }, "lastModified": 1540588091.108, "created": 1540588091.108, "arn": "arn:aws:codebuild:us-west-2:123456789012:project/test-for-sample", "secondarySources": [], "secondaryArtifacts": [], "cache": { "type": "NO_CACHE" }, "serviceRole": "arn:aws:iam::123456789012:role/service-role/my-test-role", "environment": { "image": "aws/codebuild/java:openjdk-8", "privilegedMode": true, "type": "LINUX_CONTAINER", "computeType": "BUILD_GENERAL1_SMALL", "environmentVariables": [] }, "tags": [] }, { "encryptionKey": "arn:aws:kms:us-west-2:123456789012:alias/aws/s3", "name": "my-other-demo-project", "queuedTimeoutInMinutes": 480, "timeoutInMinutes": 60, "source": { "location": "https://github.com/iversonic/codedeploy-sample.git", "reportBuildStatus": false, "buildspec": "buildspec.yml", "insecureSsl": false, "gitCloneDepth": 1, "type": "GITHUB", "auth": { "type": "OAUTH" } }, "artifacts": { "type": "NO_ARTIFACTS" }, "badge": { "badgeEnabled": false }, "lastModified": 1523401711.73, "created": 1523401711.73, "arn": "arn:aws:codebuild:us-west-2:123456789012:project/Project2", "cache": { "type": "NO_CACHE" }, "serviceRole": "arn:aws:iam::123456789012:role/service-role/codebuild-Project2-service-role", "environment": { "image": "aws/codebuild/nodejs:4.4.7", "privilegedMode": false, "type": "LINUX_CONTAINER", "computeType": "BUILD_GENERAL1_SMALL", "environmentVariables": [] }, "tags": [] } ] }
如需詳細資訊,請參閱 AWS CLI 使用者指南中的檢視建置專案的詳細資訊 (Word)。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 BatchGetProjects
。
-
下列程式碼範例示範如何使用 batch-get-report-groups
。
- AWS CLI
-
取得有關 in AWS CodeBuild 中一或多個報告群組的資訊。
下列
batch-get-report-groups
範例會使用指定的 ARN 擷取報告群組的相關資訊。aws codebuild batch-get-report-groups \ --report-group-arns
arn:aws:codebuild:<region-ID>:<user-ID>:report-group/<report-group-name>
輸出:
{ "reportGroups": [ { "arn": "arn:aws:codebuild:<region-ID>:<user-ID>:report-group/<report-group-name>", "name": "report-group-name", "type": "TEST", "exportConfig": { "exportConfigType": "NO_EXPORT" }, "created": "2020-10-01T18:04:08.466000+00:00", "lastModified": "2020-10-01T18:04:08.466000+00:00", "tags": [] } ], "reportGroupsNotFound": [] }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的使用報告群組。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 BatchGetReportGroups
。
-
下列程式碼範例示範如何使用 batch-get-reports
。
- AWS CLI
-
取得有關 in AWS CodeBuild 中一或多個報告的資訊。
下列
batch-get-reports
範例會使用指定的 ARNs 擷取報告的相關資訊。aws codebuild batch-get-reports \ --report-arns
arn:aws:codebuild:<region-ID>:<user-ID>:report/<report-group-name>:<report
1
ID>
arn:aws:codebuild:<region-ID>:<user-ID>:report/<report-group-name>:<report
2
ID>
輸出:
{ "reports": [ { "arn": "arn:aws:codebuild:<region-ID>:<user-ID>:report/<report-group-name>:<report 1 ID>", "type": "TEST", "name": "<report-group-name>", "reportGroupArn": "arn:aws:codebuild:<region-ID>:<user-ID>:report-group/<report-group-name>", "executionId": "arn:aws:codebuild:<region-ID>:<user-ID>:build/test-reports:<ID>", "status": "FAILED", "created": "2020-10-01T11:25:22.531000-07:00", "expired": "2020-10-31T11:25:22-07:00", "exportConfig": { "exportConfigType": "NO_EXPORT" }, "truncated": false, "testSummary": { "total": 28, "statusCounts": { "ERROR": 5, "FAILED": 1, "SKIPPED": 4, "SUCCEEDED": 18, "UNKNOWN": 0 }, "durationInNanoSeconds": 94000000 } }, { "arn": "arn:aws:codebuild:<region-ID>:<user-ID>:report/<report-group-name>:<report 2 ID>", "type": "TEST", "name": "<report-group-name>", "reportGroupArn": "arn:aws:codebuild:<region-ID>:<user-ID>:report-group/<report-group-name>", "executionId": "arn:aws:codebuild:<region-ID>:<user-ID>:build/test-reports:<ID>", "status": "FAILED", "created": "2020-10-01T11:13:05.816000-07:00", "expired": "2020-10-31T11:13:05-07:00", "exportConfig": { "exportConfigType": "NO_EXPORT" }, "truncated": false, "testSummary": { "total": 28, "statusCounts": { "ERROR": 5, "FAILED": 1, "SKIPPED": 4, "SUCCEEDED": 18, "UNKNOWN": 0 }, "durationInNanoSeconds": 94000000 } } ], "reportsNotFound": [] }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的使用報告。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 BatchGetReports
。
-
下列程式碼範例示範如何使用 create-project
。
- AWS CLI
-
範例 1:建立 a AWS CodeBuild 建置專案
下列
create-project
範例使用來自 S3 儲存貯體的來源檔案建立 a CodeBuild 建置專案aws codebuild create-project \ --name
"my-demo-project"
\ --source "{\"type\": \"S3\",\"location\": \"codebuild-us-west-2-123456789012-input-bucket/my-source.zip\"}" \ --artifacts {"\"type\": \"S3\",\"location\": \"codebuild-us-west-2-123456789012-output-bucket\""} \ --environment "{\"type\": \"LINUX_CONTAINER\",\"image\": \"aws/codebuild/standard:1.0\",\"computeType\": \"BUILD_GENERAL1_SMALL\"}" \ --service-role"arn:aws:iam::123456789012:role/service-role/my-codebuild-service-role"
輸出:
{ "project": { "arn": "arn:aws:codebuild:us-west-2:123456789012:project/my-demo-project", "name": "my-cli-demo-project", "encryptionKey": "arn:aws:kms:us-west-2:123456789012:alias/aws/s3", "serviceRole": "arn:aws:iam::123456789012:role/service-role/my-codebuild-service-role", "lastModified": 1556839783.274, "badge": { "badgeEnabled": false }, "queuedTimeoutInMinutes": 480, "environment": { "image": "aws/codebuild/standard:1.0", "computeType": "BUILD_GENERAL1_SMALL", "type": "LINUX_CONTAINER", "imagePullCredentialsType": "CODEBUILD", "privilegedMode": false, "environmentVariables": [] }, "artifacts": { "location": "codebuild-us-west-2-123456789012-output-bucket", "name": "my-cli-demo-project", "namespaceType": "NONE", "type": "S3", "packaging": "NONE", "encryptionDisabled": false }, "source": { "type": "S3", "location": "codebuild-us-west-2-123456789012-input-bucket/my-source.zip", "insecureSsl": false }, "timeoutInMinutes": 60, "cache": { "type": "NO_CACHE" }, "created": 1556839783.274 } }
範例 2:使用參數的 AWS CodeBuild 輸入檔案建立 JSON 建置專案
下列
create-project
範例會透過在 CodeBuild 輸入檔案中傳遞所有必要參數來建立 aJSON 建置專案。僅使用 執行 命令來建立輸入檔案範本--generate-cli-skeleton parameter
。aws codebuild create-project --cli-input-json
file://create-project.json
輸入 JSON 檔案
create-project.json
包含下列內容:{ "name": "codebuild-demo-project", "source": { "type": "S3", "location": "codebuild-region-ID-account-ID-input-bucket/MessageUtil.zip" }, "artifacts": { "type": "S3", "location": "codebuild-region-ID-account-ID-output-bucket" }, "environment": { "type": "LINUX_CONTAINER", "image": "aws/codebuild/standard:1.0", "computeType": "BUILD_GENERAL1_SMALL" }, "serviceRole": "serviceIAMRole" }
輸出:
{ "project": { "name": "codebuild-demo-project", "serviceRole": "serviceIAMRole", "tags": [], "artifacts": { "packaging": "NONE", "type": "S3", "location": "codebuild-region-ID-account-ID-output-bucket", "name": "message-util.zip" }, "lastModified": 1472661575.244, "timeoutInMinutes": 60, "created": 1472661575.244, "environment": { "computeType": "BUILD_GENERAL1_SMALL", "image": "aws/codebuild/standard:1.0", "type": "LINUX_CONTAINER", "environmentVariables": [] }, "source": { "type": "S3", "location": "codebuild-region-ID-account-ID-input-bucket/MessageUtil.zip" }, "encryptionKey": "arn:aws:kms:region-ID:account-ID:alias/aws/s3", "arn": "arn:aws:codebuild:region-ID:account-ID:project/codebuild-demo-project" } }
如需詳細資訊,請參閱 AWS CLI 使用者指南中的建立專案 (Word)。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 CreateProject
。
-
下列程式碼範例示範如何使用 create-report-group
。
- AWS CLI
-
建立 in AWS CodeBuild 的報告群組。
下列
create-report-group
範例會建立新的報告群組。aws codebuild create-report-group \ --cli-input-json
file://create-report-group-source.json
create-report-group-source.json 的內容:
{ "name": "cli-created-report-group", "type": "TEST", "exportConfig": { "exportConfigType": "S3", "s3Destination": { "bucket": "my-s3-bucket", "path": "", "packaging": "ZIP", "encryptionDisabled": true } } }
輸出:
{ "reportGroup": { "arn": "arn:aws:codebuild:<region-ID>:<user-ID>:report-group/cli-created-report-group", "name": "cli-created-report-group", "type": "TEST", "exportConfig": { "exportConfigType": "S3", "s3Destination": { "bucket": "my-s3-bucket", "path": "", "packaging": "ZIP", "encryptionDisabled": true } }, "created": 1602020026.775, "lastModified": 1602020026.775 } }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的使用報告群組。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 CreateReportGroup
。
-
下列程式碼範例示範如何使用 create-webhook
。
- AWS CLI
-
為 a AWS CodeBuild 專案建立 Webhook 篩選條件
下列
create-webhook
範例會為具有兩個篩選條件群組my-project
的名為 a CodeBuild 專案建立 Webhook。第一個篩選群組指定在分支上建立、更新或重新開啟的提取請求,並且這些分支的 Git 參考名稱符合規則表達式^refs/heads/master$
,而標頭參考符合^refs/heads/myBranch$
。第二個篩選條件群組指定分支上的推送請求,其 Git 參考名稱與規則表達式 不相符^refs/heads/myBranch$
。aws codebuild create-webhook \ --project-name
my-project
\ --filter-groups "[[{\"type\":\"EVENT\",\"pattern\":\"PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_REOPENED\"},{\"type\":\"HEAD_REF\",\"pattern\":\"^refs/heads/myBranch$\",\"excludeMatchedPattern\":true},{\"type\":\"BASE_REF\",\"pattern\":\"^refs/heads/master$\",\"excludeMatchedPattern\":true}],[{\"type\":\"EVENT\",\"pattern\":\"PUSH\"},{\"type\":\"HEAD_REF\",\"pattern\":\"^refs/heads/myBranch$\",\"excludeMatchedPattern\":true}]]"輸出:
{ "webhook": { "payloadUrl": "https://codebuild.us-west-2.amazonaws.com/webhooks?t=eyJlbmNyeXB0ZWREYXRhIjoiVVl5MGtoeGRwSzZFRXl2Wnh4bld1Z0tKZ291TVpQNEtFamQ3RDlDYWpRaGIreVFrdm9EQktIVk1NeHJEWEpmUDUrVUNOMUIyRHJRc1VxcHJ6QlNDSnljPSIsIml2UGFyYW1ldGVyU3BlYyI6InN4Tm1SeUt5MUhaUVRWbGciLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&v=1", "url": "https://api.github.com/repos/iversonic/codedeploy-sample/hooks/105190656", "lastModifiedSecret": 1556311319.069, "filterGroups": [ [ { "type": "EVENT", "pattern": "PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_REOPENED", "excludeMatchedPattern": false }, { "type": "HEAD_REF", "pattern": "refs/heads/myBranch$", "excludeMatchedPattern": true }, { "type": "BASE_REF", "pattern": "refs/heads/master$", "excludeMatchedPattern": true } ], [ { "type": "EVENT", "pattern": "PUSH", "excludeMatchedPattern": false }, { "type": "HEAD_REF", "pattern": "refs/heads/myBranch$", "excludeMatchedPattern": true } ] ] } }
如需詳細資訊,請參閱 SDK 使用者指南中的 Filter GitHub Webhook Events (Word)。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 CreateWebhook
。
-
下列程式碼範例示範如何使用 delete-build-batch
。
- AWS CLI
-
刪除 in AWS CodeBuild 中的批次建置。
下列
delete-build-batch
範例會刪除指定的批次建置。aws codebuild delete-build-batch \ --id
<project-name>:<batch-ID>
輸出:
{ "statusCode": "BATCH_DELETED", "buildsDeleted": [ "arn:aws:codebuild:<region-ID>:<account-ID>:build/<project-name>:<build-ID>", "arn:aws:codebuild:<region-ID>:<account-ID>:build/<project-name>:<build-ID>", "arn:aws:codebuild:<region-ID>:<account-ID>:build/<project-name>:<build-ID>", "arn:aws:codebuild:<region-ID>:<account-ID>:build/<project-name>:<build-ID>" ], "buildsNotDeleted": [] }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的批次建置 inWordAWS CodeBuild 。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DeleteBuildBatch
。
-
下列程式碼範例示範如何使用 delete-project
。
- AWS CLI
-
若要刪除 a AWS CodeBuild 建置專案
下列
delete-project
範例會刪除指定的 CodeBuild 建置專案。aws codebuild delete-project --name
my-project
此命令不會產生輸出。
如需詳細資訊,請參閱 AWS CLI 使用者指南中的刪除建置專案 (Word)。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DeleteProject
。
-
下列程式碼範例示範如何使用 delete-report-group
。
- AWS CLI
-
刪除 in AWS CodeBuild 中的報告群組。
下列
delete-report-group
範例會刪除具有指定 ARN 的報告群組。aws codebuild delete-report-group \ --arn
arn:aws:codebuild:<region-ID>:<user-ID>:report-group/<report-group-name>
此命令不會產生輸出。
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的使用報告群組。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DeleteReportGroup
。
-
下列程式碼範例示範如何使用 delete-report
。
- AWS CLI
-
若要刪除 in AWS CodeBuild 中的報告。
下列
delete-report
範例會刪除指定的報告。aws codebuild delete-report \ --arn
arn:aws:codebuild:<region-ID>:<account-ID>:report/<report-group-name>:<report-ID>
此命令不會產生輸出。
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的使用報告。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DeleteReport
。
-
下列程式碼範例示範如何使用 delete-source-credentials
。
- AWS CLI
-
中斷與來源提供者的連線,並移除其存取權杖。
下列
delete-source-credentials
範例會中斷與來源提供者的連線,並移除其權杖。用於連線至來源提供者的來源憑證 ARN 會決定哪個來源憑證。aws codebuild delete-source-credentials --arn
arn-of-your-credentials
輸出:
{ "arn": "arn:aws:codebuild:your-region:your-account-id:token/your-server-type" }
如需詳細資訊,請參閱 Word 使用者指南中的將來源提供者與存取符記 (WordCLI) 連接。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DeleteSourceCredentials
。
-
下列程式碼範例示範如何使用 delete-webhook
。
- AWS CLI
-
從 a AWS CodeBuild 專案刪除 Webhook 篩選條件
下列
delete-webhook
範例會從指定的 CodeBuild 專案中刪除 Webhook。aws codebuild delete-webhook --project-name
my-project
此命令不會產生輸出。
如需詳細資訊,請參閱 AWS CLI 使用者指南中的停止自動執行建置 (Word)。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DeleteWebhook
。
-
下列程式碼範例示範如何使用 describe-code-coverages
。
- AWS CLI
-
若要在 AWS CodeBuild 中取得程式碼涵蓋範圍測試結果的詳細資訊。
下列
describe-code-coverages
範例會在指定的報告中取得程式碼涵蓋範圍測試結果的相關資訊。aws codebuild describe-code-coverages \ --report-arn
arn:aws:codebuild:<region-ID>:<account-ID>:report/<report-group-name>:<report-ID>
輸出:
{ "codeCoverages": [ { "id": "20a0adcc-db13-4b66-804b-ecaf9f852855", "reportARN": "arn:aws:codebuild:<region-ID>:972506530580:report/<report-group-name>:<report-ID>", "filePath": "<source-file-1-path>", "lineCoveragePercentage": 83.33, "linesCovered": 5, "linesMissed": 1, "branchCoveragePercentage": 50.0, "branchesCovered": 1, "branchesMissed": 1, "expired": "2020-11-20T21:22:45+00:00" }, { "id": "0887162d-bf57-4cf1-a164-e432373d1a83", "reportARN": "arn:aws:codebuild:<region-ID>:972506530580:report/<report-group-name>:<report-ID>", "filePath": "<source-file-2-path>", "lineCoveragePercentage": 90.9, "linesCovered": 10, "linesMissed": 1, "branchCoveragePercentage": 50.0, "branchesCovered": 1, "branchesMissed": 1, "expired": "2020-11-20T21:22:45+00:00" } ] }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的程式碼涵蓋範圍報告。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribeCodeCoverages
。
-
下列程式碼範例示範如何使用 describe-test-cases
。
- AWS CLI
-
取得測試案例 in AWS CodeBuild 的詳細資訊。
下列
describe-test-cases
範例取得指定報告中測試案例的相關資訊。aws codebuild describe-test-cases \ --report-arn
arn:aws:codebuild:<region-ID>:<account-ID>:report/<report-group-name>:<report-ID>
輸出:
{ "testCases": [ { "reportArn": "arn:aws:codebuild:<region-ID>:<account-ID>:report/<report-group-name>:<report-ID>", "testRawDataPath": "<test-report-path>", "prefix": "NUnit.Tests.Assemblies.MockTestFixture", "name": "NUnit.Tests.Assemblies.MockTestFixture.NotRunnableTest", "status": "ERROR", "durationInNanoSeconds": 0, "message": "No arguments were provided\n", "expired": "2020-11-20T17:52:10+00:00" }, { "reportArn": "arn:aws:codebuild:<region-ID>:<account-ID>:report/<report-group-name>:<report-ID>", "testRawDataPath": "<test-report-path>", "prefix": "NUnit.Tests.Assemblies.MockTestFixture", "name": "NUnit.Tests.Assemblies.MockTestFixture.TestWithException", "status": "ERROR", "durationInNanoSeconds": 0, "message": "System.ApplicationException : Intentional Exception\nat NUnit.Tests.Assemblies.MockTestFixture.MethodThrowsException()\nat NUnit.Tests.Assemblies.MockTestFixture.TestWithException()\n\n", "expired": "2020-11-20T17:52:10+00:00" } ] }
如需詳細資訊,請參閱 Word 使用者指南中的使用 in AWS CodeBuild 測試報告。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribeTestCases
。
-
下列程式碼範例示範如何使用 import-source-credentials
。
- AWS CLI
-
透過匯入來源提供者的憑證,將 a AWS CodeBuild 使用者連線至來源提供者。
下列
import-source-credentials
範例會為使用 BASIC_AUTH 進行身分驗證類型的 Bitbucket 儲存庫匯入權杖。aws codebuild import-source-credentials --server-type
BITBUCKET
--auth-typeBASIC_AUTH
--tokenmy-Bitbucket-password
--usernamemy-Bitbucket-username
輸出:
{ "arn": "arn:aws:codebuild:us-west-2:123456789012:token/bitbucket" }
如需詳細資訊,請參閱 Word 使用者指南中的將來源提供者與存取權杖 (WordCLI) 連線。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ImportSourceCredentials
。
-
下列程式碼範例示範如何使用 invalidate-project-cache
。
- AWS CLI
-
重設 an AWS CodeBuild 建置專案的快取。
下列
invalidate-project-cache
範例會重設指定 CodeBuild 專案的快取。aws codebuild invalidate-project-cache --project-name
my-project
此命令不會產生輸出。
如需詳細資訊,請參閱 CodeBuild 使用者指南中的建置快取 inWordAWS CodeBuild 。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 InvalidateProjectCache
。
-
下列程式碼範例示範如何使用 list-build-batches-for-project
。
- AWS CLI
-
列出 in AWS CodeBuild 中特定建置專案的批次建置。
下列
list-build-batches-for-project
範例列出指定專案的 CodeBuild 批次建置。aws codebuild list-build-batches-for-project \ --project-name
"<project-name>"
輸出:
{ "ids": [ "<project-name>:<batch-ID>", "<project-name>:<batch-ID>" ] }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的批次建置 inWordAWS CodeBuild 。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListBuildBatchesForProject
。
-
下列程式碼範例示範如何使用 list-build-batches
。
- AWS CLI
-
列出 in AWS CodeBuild 中的批次建置。
下列
list-build-batches
範例列出目前帳戶的 CodeBuild 批次建置。aws codebuild list-build-batches
輸出:
{ "ids": [ "<project-name>:<batch-ID>", "<project-name>:<batch-ID>" ] }
如需詳細資訊,請參閱 AWS CodeBuild AWS 使用者指南中的批次建置 inCodeBuild <latest/userguide/batchhttps://docs.aws.amazon.com/codebuild/-build.html>)__。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListBuildBatches
。
-
下列程式碼範例示範如何使用 list-builds-for-project
。
- AWS CLI
-
檢視 a AWS CodeBuild 建置專案的建置清單。
下列
list-builds-for-project
範例會列出指定 IDs 建置專案的建置 CodeBuild 遞減順序。aws codebuild list-builds-for-project --project-name
codebuild-demo-project
--sort-orderDESCENDING
輸出:
{ "ids": [ "codebuild-demo-project:1a2b3c4d-5678-90ab-cdef-11111example", "codebuild-demo-project:1a2b3c4d-5678-90ab-cdef-22222example", "codebuild-demo-project:1a2b3c4d-5678-90ab-cdef-33333example", "codebuild-demo-project:1a2b3c4d-5678-90ab-cdef-44444example", "codebuild-demo-project:1a2b3c4d-5678-90ab-cdef-55555example" ] }
如需詳細資訊,請參閱 IDs 使用者指南中的檢視建置專案的建置 Word 清單 (AWS CLI) AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListBuildsForProject
。
-
下列程式碼範例示範如何使用 list-builds
。
- AWS CLI
-
若要取得 AWS CodeBuild 組建 IDs 的清單。
下列
list-builds
範例會取得以遞增順序排序的 CodeBuild IDs Word清單。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" ] }
如需詳細資訊,請參閱 IDs 使用者指南中的檢視建置AWS CLI (Word) 清單 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListBuilds
。
-
下列程式碼範例示範如何使用 list-curated-environment-images
。
- AWS CLI
-
取得由 AWS CodeBuild 管理的 Docker 映像清單,可用於建置。
下列
list-curated-environment-images
範例列出由 CodeBuild 管理的 Docker 映像,可用於建置。:aws codebuild list-curated-environment-images
輸出:
{ "platforms": [ { "platform": "AMAZON_LINUX", "languages": [ { "language": "JAVA", "images": [ { "description": "AWS ElasticBeanstalk - Java 7 Running on Amazon Linux 64bit v2.1.3", "name": "aws/codebuild/eb-java-7-amazonlinux-64:2.1.3", "versions": [ "aws/codebuild/eb-java-7-amazonlinux-64:2.1.3-1.0.0" ] }, { "description": "AWS ElasticBeanstalk - Java 8 Running on Amazon Linux 64bit v2.1.3", "name": "aws/codebuild/eb-java-8-amazonlinux-64:2.1.3", "versions": [ "aws/codebuild/eb-java-8-amazonlinux-64:2.1.3-1.0.0" ] }, ... LIST TRUNCATED FOR BREVITY ... ] } ] } ] }
如需詳細資訊,請參閱 CodeBuild 使用者指南中的 Docker Images provided byWordAWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListCuratedEnvironmentImages
。
-
下列程式碼範例示範如何使用 list-projects
。
- AWS CLI
-
取得 AWS CodeBuild 組建專案名稱的清單。
下列
list-projects
範例會取得依名稱遞增排序的 CodeBuild 組建專案清單。aws codebuild list-projects --sort-by
NAME
--sort-orderASCENDING
輸出包含一個
nextToken
值,指出有更多可用的輸出。{ "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" ] }
再次執行此命令,並提供上一個回應
nextToken
的值做為 參數,以取得輸出的下一個部分。重複此動作,直到您未在回應中收到nextToken
值為止。aws codebuild list-projects --sort-by
NAME
--sort-orderASCENDING
--next-tokenCi33ACF6...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"
]
}
如需詳細資訊,請參閱 AWS CLI 使用者指南中的檢視建置專案名稱清單 (Word)。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListProjects
。
-
下列程式碼範例示範如何使用 list-report-groups
。
- AWS CLI
-
取得報告群組 ARNs in AWS CodeBuild 的清單。
下列
list-report-groups
範例會擷取 區域中 帳戶的報告群組 ARNs。aws codebuild list-report-groups
輸出:
{ "reportGroups": [ "arn:aws:codebuild:<region-ID>:<user-ID>:report-group/report-group-1", "arn:aws:codebuild:<region-ID>:<user-ID>:report-group/report-group-2", "arn:aws:codebuild:<region-ID>:<user-ID>:report-group/report-group-3" ] }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的使用報告群組。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListReportGroups
。
-
下列程式碼範例示範如何使用 list-reports-for-report-group
。
- AWS CLI
-
取得 in AWS CodeBuild 中報告群組的報告清單。
下列
list-report-for-report-groups
範例會擷取 區域中帳戶在指定報告群組中的報告。aws codebuild list-reports-for-report-group \ --report-group-arn
arn:aws:codebuild:<region-ID>:<user-ID>:report-group/<report-group-name>
輸出:
{ "reports": [ "arn:aws:codebuild:<region-ID>:<user-ID>:report/report-1", "arn:aws:codebuild:<region-ID>:<user-ID>:report/report-2", "arn:aws:codebuild:<region-ID>:<user-ID>:report/report-3" ] }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的使用報告群組。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListReportsForReportGroup
。
-
下列程式碼範例示範如何使用 list-reports
。
- AWS CLI
-
取得目前帳戶 in AWS CodeBuild 的報告清單。
下列
list-reports
範例會擷取目前帳戶的報告的 ARNs。aws codebuild list-reports
輸出:
{ "reports": [ "arn:aws:codebuild:<region-ID>:<user-ID>:report/<report-group-name>:<report ID>", "arn:aws:codebuild:<region-ID>:<user-ID>:report/<report-group-name>:<report ID>", "arn:aws:codebuild:<region-ID>:<user-ID>:report/<report-group-name>:<report ID>" ] }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的使用報告。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListReports
。
-
下列程式碼範例示範如何使用 list-shared-projects
。
- AWS CLI
-
列出 in AWS CodeBuild 中的共用專案。
下列
list-shared-projects
範例列出目前帳戶可用的 CodeBuild 共用專案。aws codebuild list-shared-projects
輸出:
{ "projects": [ "arn:aws:codebuild:<region-ID>:<account-ID>:project/<shared-project-name-1>", "arn:aws:codebuild:<region-ID>:<account-ID>:project/<shared-project-name-2>" ] }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的使用共用專案。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListSharedProjects
。
-
下列程式碼範例示範如何使用 list-shared-report-groups
。
- AWS CLI
-
取得共用報告群組 ARNs in AWS CodeBuild 的清單。
下列
list-shared-report-groups
範例會擷取 區域中 帳戶的報告群組 ARNs。aws codebuild list-shared-report-groups
輸出:
{ "reportGroups": [ "arn:aws:codebuild:<region-ID>:<user-ID>:report-group/report-group-1", "arn:aws:codebuild:<region-ID>:<user-ID>:report-group/report-group-2", "arn:aws:codebuild:<region-ID>:<user-ID>:report-group/report-group-3" ] }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的使用報告群組。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListSharedReportGroups
。
-
下列程式碼範例示範如何使用 list-source-credentials
。
- AWS CLI
-
檢視 sourceCredentialsObjects 清單
下列
list-source-credentials
範例會列出連線至一個 Bitbucket AWS 帳戶和 one GitHub 帳戶的權杖。回應中的每個sourceCredentialsInfos
物件都包含連線的來源憑證資訊。aws codebuild list-source-credentials
輸出:
{ "sourceCredentialsInfos": [ { "serverType": "BITBUCKET", "arn": "arn:aws:codebuild:us-west-2:123456789012:token/bitbucket", "authType": "BASIC_AUTH" }, { "serverType": "GITHUB", "arn": "arn:aws:codebuild:us-west-2:123456789012:token/github", "authType": "OAUTH" } ] }
如需詳細資訊,請參閱 Word 使用者指南中的將來源提供者與存取符記 (WordCLI) 連接。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListSourceCredentials
。
-
下列程式碼範例示範如何使用 retry-build-batch
。
- AWS CLI
-
若要重試失敗的批次建置 in AWS CodeBuild。
下列
retry-build-batch
範例會重新啟動指定的批次建置。aws codebuild retry-build-batch \ --id
<project-name>:<batch-ID>
輸出:
{ "buildBatch": { "id": "<project-name>:<batch-ID>", "arn": "arn:aws:codebuild:<region-ID>:<account-ID>:build-batch/<project-name>:<batch-ID>", "startTime": "2020-10-21T17:26:23.099000+00:00", "currentPhase": "SUBMITTED", "buildBatchStatus": "IN_PROGRESS", "resolvedSourceVersion": "3a9e11cb419e8fff14b03883dc4e64f6155aaa7e", "projectName": "<project-name>", "phases": [ { "phaseType": "SUBMITTED", "phaseStatus": "SUCCEEDED", "startTime": "2020-10-21T17:26:23.099000+00:00", "endTime": "2020-10-21T17:26:23.457000+00:00", "durationInSeconds": 0 }, { "phaseType": "DOWNLOAD_BATCHSPEC", "phaseStatus": "SUCCEEDED", "startTime": "2020-10-21T17:26:23.457000+00:00", "endTime": "2020-10-21T17:26:54.902000+00:00", "durationInSeconds": 31 }, { "phaseType": "IN_PROGRESS", "phaseStatus": "CLIENT_ERROR", "startTime": "2020-10-21T17:26:54.902000+00:00", "endTime": "2020-10-21T17:28:16.060000+00:00", "durationInSeconds": 81 }, { "phaseType": "FAILED", "phaseStatus": "RETRY", "startTime": "2020-10-21T17:28:16.060000+00:00", "endTime": "2020-10-21T17:29:39.709000+00:00", "durationInSeconds": 83 }, { "phaseType": "SUBMITTED", "startTime": "2020-10-21T17:29:39.709000+00:00" } ], "source": { "type": "GITHUB", "location": "https://github.com/strohm-a/<project-name>-graph.git", "gitCloneDepth": 1, "gitSubmodulesConfig": { "fetchSubmodules": false }, "reportBuildStatus": false, "insecureSsl": false }, "secondarySources": [], "secondarySourceVersions": [], "artifacts": { "location": "" }, "secondaryArtifacts": [], "cache": { "type": "NO_CACHE" }, "environment": { "type": "LINUX_CONTAINER", "image": "aws/codebuild/amazonlinux2-x86_64-standard:3.0", "computeType": "BUILD_GENERAL1_SMALL", "environmentVariables": [], "privilegedMode": false, "imagePullCredentialsType": "CODEBUILD" }, "logConfig": { "cloudWatchLogs": { "status": "ENABLED" }, "s3Logs": { "status": "DISABLED", "encryptionDisabled": false } }, "buildTimeoutInMinutes": 60, "queuedTimeoutInMinutes": 480, "complete": false, "initiator": "<username>", "encryptionKey": "arn:aws:kms:<region-ID>:<account-ID>:alias/aws/s3", "buildBatchNumber": 4, "buildBatchConfig": { "serviceRole": "arn:aws:iam::<account-ID>:role/service-role/<project-name>", "restrictions": { "maximumBuildsAllowed": 100 }, "timeoutInMins": 480 }, "buildGroups": [ { "identifier": "DOWNLOAD_SOURCE", "ignoreFailure": false, "currentBuildSummary": { "arn": "arn:aws:codebuild:<region-ID>:<account-ID>:build/<project-name>:<build-ID>", "requestedOn": "2020-10-21T17:26:23.889000+00:00", "buildStatus": "SUCCEEDED", "primaryArtifact": { "type": "no_artifacts", "identifier": "DOWNLOAD_SOURCE" }, "secondaryArtifacts": [] } }, { "identifier": "linux_small", "dependsOn": [], "ignoreFailure": false, "currentBuildSummary": { "arn": "arn:aws:codebuild:<region-ID>:<account-ID>:build/<project-name>:<build-ID>", "requestedOn": "2020-10-21T17:26:55.115000+00:00", "buildStatus": "FAILED", "primaryArtifact": { "type": "no_artifacts", "identifier": "linux_small" }, "secondaryArtifacts": [] } }, { "identifier": "linux_medium", "dependsOn": [ "linux_small" ], "ignoreFailure": false, "currentBuildSummary": { "arn": "arn:aws:codebuild:<region-ID>:<account-ID>:build/<project-name>:<build-ID>", "requestedOn": "2020-10-21T17:26:54.594000+00:00", "buildStatus": "STOPPED" } }, { "identifier": "linux_large", "dependsOn": [ "linux_medium" ], "ignoreFailure": false, "currentBuildSummary": { "arn": "arn:aws:codebuild:<region-ID>:<account-ID>:build/<project-name>:<build-ID>", "requestedOn": "2020-10-21T17:26:54.701000+00:00", "buildStatus": "STOPPED" } } ] } }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的批次建置 inWordAWS CodeBuild 。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 RetryBuildBatch
。
-
下列程式碼範例示範如何使用 retry-build
。
- AWS CLI
-
若要重試失敗的 in AWS CodeBuild 建置。
下列
retry-build
範例會重新啟動指定的建置。aws codebuild retry-build \ --id
<project-name>:<build-ID>
輸出:
{ "build": { "id": "<project-name>:<build-ID>", "arn": "arn:aws:codebuild:<region-ID>:<account-ID>:build/<project-name>:<build-ID>", "buildNumber": 9, "startTime": "2020-10-21T17:51:38.161000+00:00", "currentPhase": "QUEUED", "buildStatus": "IN_PROGRESS", "projectName": "<project-name>", "phases": [ { "phaseType": "SUBMITTED", "phaseStatus": "SUCCEEDED", "startTime": "2020-10-21T17:51:38.161000+00:00", "endTime": "2020-10-21T17:51:38.210000+00:00", "durationInSeconds": 0 }, { "phaseType": "QUEUED", "startTime": "2020-10-21T17:51:38.210000+00:00" } ], "source": { "type": "GITHUB", "location": "<GitHub-repo-URL>", "gitCloneDepth": 1, "gitSubmodulesConfig": { "fetchSubmodules": false }, "reportBuildStatus": false, "insecureSsl": false }, "secondarySources": [], "secondarySourceVersions": [], "artifacts": { "location": "" }, "secondaryArtifacts": [], "cache": { "type": "NO_CACHE" }, "environment": { "type": "LINUX_CONTAINER", "image": "aws/codebuild/amazonlinux2-x86_64-standard:3.0", "computeType": "BUILD_GENERAL1_SMALL", "environmentVariables": [], "privilegedMode": false, "imagePullCredentialsType": "CODEBUILD" }, "serviceRole": "arn:aws:iam::<account-ID>:role/service-role/<service-role-name>", "logs": { "deepLink": "https://console.aws.amazon.com/cloudwatch/home?region=<region-ID>#logEvent:group=null;stream=null", "cloudWatchLogsArn": "arn:aws:logs:<region-ID>:<account-ID>:log-group:null:log-stream:null", "cloudWatchLogs": { "status": "ENABLED" }, "s3Logs": { "status": "DISABLED", "encryptionDisabled": false } }, "timeoutInMinutes": 60, "queuedTimeoutInMinutes": 480, "buildComplete": false, "initiator": "<username>", "encryptionKey": "arn:aws:kms:<region-ID>:<account-ID>:alias/aws/s3" } }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的批次建置 inWordAWS CodeBuild 。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 RetryBuild
。
-
下列程式碼範例示範如何使用 start-build-batch
。
- AWS CLI
-
啟動 in AWS CodeBuild 中的批次建置。
下列
start-build-batch
範例會啟動指定專案的批次建置。aws codebuild start-build-batch \ --project-name
<project-name>
輸出:
{ "buildBatch": { "id": "<project-name>:<batch-ID>", "arn": "arn:aws:codebuild:<region-ID>:<account-ID>:build-batch/<project-name>:<batch-ID>", "startTime": "2020-10-21T16:54:24.740000+00:00", "currentPhase": "SUBMITTED", "buildBatchStatus": "IN_PROGRESS", "projectName": "<project-name>", "source": { "type": "GITHUB", "location": "<GitHub-repo-URL>", "gitCloneDepth": 1, "gitSubmodulesConfig": { "fetchSubmodules": false }, "reportBuildStatus": false, "insecureSsl": false }, "secondarySources": [], "secondarySourceVersions": [], "artifacts": { "location": "" }, "secondaryArtifacts": [], "cache": { "type": "NO_CACHE" }, "environment": { "type": "LINUX_CONTAINER", "image": "aws/codebuild/amazonlinux2-x86_64-standard:3.0", "computeType": "BUILD_GENERAL1_SMALL", "environmentVariables": [], "privilegedMode": false, "imagePullCredentialsType": "CODEBUILD" }, "logConfig": { "cloudWatchLogs": { "status": "ENABLED" }, "s3Logs": { "status": "DISABLED", "encryptionDisabled": false } }, "buildTimeoutInMinutes": 60, "queuedTimeoutInMinutes": 480, "complete": false, "initiator": "<username>", "encryptionKey": "arn:aws:kms:<region-ID>:<account-ID>:alias/aws/s3", "buildBatchNumber": 3, "buildBatchConfig": { "serviceRole": "arn:aws:iam::<account-ID>:role/service-role/<service-role-name>", "restrictions": { "maximumBuildsAllowed": 100 }, "timeoutInMins": 480 } } }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的批次建置 inWordAWS CodeBuild 。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 StartBuildBatch
。
-
下列程式碼範例示範如何使用 start-build
。
- AWS CLI
-
開始執行建置 a AWS CodeBuild 建置專案。
下列
start-build
範例會啟動指定 CodeBuild 專案的建置。建置會覆寫專案的設定,以允許在建置逾時前佇列的分鐘數,以及專案的成品設定。aws codebuild start-build \ --project-name
"my-demo-project"
\ --queued-timeout-in-minutes-override5
\ --artifacts-override {"\"type\": \"S3\",\"location\": \"arn:aws:s3:::artifacts-override\",\"overrideArtifactName\":true"}輸出:
{ "build": { "serviceRole": "arn:aws:iam::123456789012:role/service-role/my-codebuild-service-role", "buildStatus": "IN_PROGRESS", "buildComplete": false, "projectName": "my-demo-project", "timeoutInMinutes": 60, "source": { "insecureSsl": false, "type": "S3", "location": "codebuild-us-west-2-123456789012-input-bucket/my-source.zip" }, "queuedTimeoutInMinutes": 5, "encryptionKey": "arn:aws:kms:us-west-2:123456789012:alias/aws/s3", "currentPhase": "QUEUED", "startTime": 1556905683.568, "environment": { "computeType": "BUILD_GENERAL1_MEDIUM", "environmentVariables": [], "type": "LINUX_CONTAINER", "privilegedMode": false, "image": "aws/codebuild/standard:1.0", "imagePullCredentialsType": "CODEBUILD" }, "phases": [ { "phaseStatus": "SUCCEEDED", "startTime": 1556905683.568, "phaseType": "SUBMITTED", "durationInSeconds": 0, "endTime": 1556905684.524 }, { "startTime": 1556905684.524, "phaseType": "QUEUED" } ], "logs": { "deepLink": "https://console.aws.amazon.com/cloudwatch/home?region=us-west-2#logEvent:group=null;stream=null" }, "artifacts": { "encryptionDisabled": false, "location": "arn:aws:s3:::artifacts-override/my-demo-project", "overrideArtifactName": true }, "cache": { "type": "NO_CACHE" }, "id": "my-demo-project::12345678-a1b2-c3d4-e5f6-11111EXAMPLE", "initiator": "my-aws-account-name", "arn": "arn:aws:codebuild:us-west-2:123456789012:build/my-demo-project::12345678-a1b2-c3d4-e5f6-11111EXAMPLE" } }
如需詳細資訊,請參閱 AWS CLI 使用者指南中的執行建置 (Word)。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 StartBuild
。
-
下列程式碼範例示範如何使用 stop-build-batch
。
- AWS CLI
-
若要停止 in AWS CodeBuild 中的進行中批次建置。
下列
stop-build-batch
範例會停止指定的批次建置。aws codebuild stop-build-batch \ --id
<project-name>:<batch-ID>
輸出:
{ "buildBatch": { "id": "<project-name>:<batch-ID>", "arn": "arn:aws:codebuild:<region-ID>:<account-ID>:build-batch/<project-name>:<batch-ID>", "startTime": "2020-10-21T16:54:24.740000+00:00", "endTime": "2020-10-21T16:56:05.152000+00:00", "currentPhase": "STOPPED", "buildBatchStatus": "STOPPED", "resolvedSourceVersion": "aef7744ed069c51098e15c360f4102cd2cd1ad64", "projectName": "<project-name>", "phases": [ { "phaseType": "SUBMITTED", "phaseStatus": "SUCCEEDED", "startTime": "2020-10-21T16:54:24.740000+00:00", "endTime": "2020-10-21T16:54:25.039000+00:00", "durationInSeconds": 0 }, { "phaseType": "DOWNLOAD_BATCHSPEC", "phaseStatus": "SUCCEEDED", "startTime": "2020-10-21T16:54:25.039000+00:00", "endTime": "2020-10-21T16:54:56.583000+00:00", "durationInSeconds": 31 }, { "phaseType": "IN_PROGRESS", "phaseStatus": "STOPPED", "startTime": "2020-10-21T16:54:56.583000+00:00", "endTime": "2020-10-21T16:56:05.152000+00:00", "durationInSeconds": 68 }, { "phaseType": "STOPPED", "startTime": "2020-10-21T16:56:05.152000+00:00" } ], "source": { "type": "GITHUB", "location": "<GitHub-repo-URL>", "gitCloneDepth": 1, "gitSubmodulesConfig": { "fetchSubmodules": false }, "reportBuildStatus": false, "insecureSsl": false }, "secondarySources": [], "secondarySourceVersions": [], "artifacts": { "location": "" }, "secondaryArtifacts": [], "cache": { "type": "NO_CACHE" }, "environment": { "type": "LINUX_CONTAINER", "image": "aws/codebuild/amazonlinux2-x86_64-standard:3.0", "computeType": "BUILD_GENERAL1_SMALL", "environmentVariables": [], "privilegedMode": false, "imagePullCredentialsType": "CODEBUILD" }, "logConfig": { "cloudWatchLogs": { "status": "ENABLED" }, "s3Logs": { "status": "DISABLED", "encryptionDisabled": false } }, "buildTimeoutInMinutes": 60, "queuedTimeoutInMinutes": 480, "complete": true, "initiator": "Strohm", "encryptionKey": "arn:aws:kms:<region-ID>:<account-ID>:alias/aws/s3", "buildBatchNumber": 3, "buildBatchConfig": { "serviceRole": "arn:aws:iam::<account-ID>:role/service-role/<project-name>", "restrictions": { "maximumBuildsAllowed": 100 }, "timeoutInMins": 480 }, "buildGroups": [ { "identifier": "DOWNLOAD_SOURCE", "ignoreFailure": false, "currentBuildSummary": { "arn": "arn:aws:codebuild:<region-ID>:<account-ID>:build/<project-name>:<build-ID>", "requestedOn": "2020-10-21T16:54:25.468000+00:00", "buildStatus": "SUCCEEDED", "primaryArtifact": { "type": "no_artifacts", "identifier": "DOWNLOAD_SOURCE" }, "secondaryArtifacts": [] } }, { "identifier": "linux_small", "dependsOn": [], "ignoreFailure": false, "currentBuildSummary": { "arn": "arn:aws:codebuild:<region-ID>:<account-ID>:build/<project-name>:<build-ID>", "requestedOn": "2020-10-21T16:54:56.833000+00:00", "buildStatus": "IN_PROGRESS" } }, { "identifier": "linux_medium", "dependsOn": [ "linux_small" ], "ignoreFailure": false, "currentBuildSummary": { "arn": "arn:aws:codebuild:<region-ID>:<account-ID>:build/<project-name>:<build-ID>", "requestedOn": "2020-10-21T16:54:56.211000+00:00", "buildStatus": "PENDING" } }, { "identifier": "linux_large", "dependsOn": [ "linux_medium" ], "ignoreFailure": false, "currentBuildSummary": { "arn": "arn:aws:codebuild:<region-ID>:<account-ID>:build/<project-name>:<build-ID>", "requestedOn": "2020-10-21T16:54:56.330000+00:00", "buildStatus": "PENDING" } } ] } }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的批次建置 inWordAWS CodeBuild 。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 StopBuildBatch
。
-
下列程式碼範例示範如何使用 stop-build
。
- AWS CLI
-
停止建置 a AWS CodeBuild 建置專案。
下列
stop-build
範例會停止指定的 CodeBuild 建置。aws codebuild stop-build --id
my-demo-project:12345678-a1b2-c3d4-e5f6-11111EXAMPLE
輸出:
{ "build": { "startTime": 1556906956.318, "initiator": "my-aws-account-name", "projectName": "my-demo-project", "currentPhase": "COMPLETED", "cache": { "type": "NO_CACHE" }, "source": { "insecureSsl": false, "location": "codebuild-us-west-2-123456789012-input-bucket/my-source.zip", "type": "S3" }, "id": "my-demo-project:1a2b3c4d-5678-90ab-cdef-11111EXAMPLE", "endTime": 1556906974.781, "phases": [ { "durationInSeconds": 0, "phaseType": "SUBMITTED", "endTime": 1556906956.935, "phaseStatus": "SUCCEEDED", "startTime": 1556906956.318 }, { "durationInSeconds": 1, "phaseType": "QUEUED", "endTime": 1556906958.272, "phaseStatus": "SUCCEEDED", "startTime": 1556906956.935 }, { "phaseType": "PROVISIONING", "phaseStatus": "SUCCEEDED", "durationInSeconds": 14, "contexts": [ { "message": "", "statusCode": "" } ], "endTime": 1556906972.847, "startTime": 1556906958.272 }, { "phaseType": "DOWNLOAD_SOURCE", "phaseStatus": "SUCCEEDED", "durationInSeconds": 0, "contexts": [ { "message": "", "statusCode": "" } ], "endTime": 1556906973.552, "startTime": 1556906972.847 }, { "phaseType": "INSTALL", "phaseStatus": "SUCCEEDED", "durationInSeconds": 0, "contexts": [ { "message": "", "statusCode": "" } ], "endTime": 1556906973.75, "startTime": 1556906973.552 }, { "phaseType": "PRE_BUILD", "phaseStatus": "SUCCEEDED", "durationInSeconds": 0, "contexts": [ { "message": "", "statusCode": "" } ], "endTime": 1556906973.937, "startTime": 1556906973.75 }, { "durationInSeconds": 0, "phaseType": "BUILD", "endTime": 1556906974.781, "phaseStatus": "STOPPED", "startTime": 1556906973.937 }, { "phaseType": "COMPLETED", "startTime": 1556906974.781 } ], "artifacts": { "location": "arn:aws:s3:::artifacts-override/my-demo-project", "encryptionDisabled": false, "overrideArtifactName": true }, "buildComplete": true, "buildStatus": "STOPPED", "encryptionKey": "arn:aws:kms:us-west-2:123456789012:alias/aws/s3", "serviceRole": "arn:aws:iam::123456789012:role/service-role/my-codebuild-service-role", "queuedTimeoutInMinutes": 5, "timeoutInMinutes": 60, "environment": { "type": "LINUX_CONTAINER", "environmentVariables": [], "computeType": "BUILD_GENERAL1_MEDIUM", "privilegedMode": false, "image": "aws/codebuild/standard:1.0", "imagePullCredentialsType": "CODEBUILD" }, "logs": { "streamName": "1a2b3c4d-5678-90ab-cdef-11111EXAMPLE", "deepLink": "https://console.aws.amazon.com/cloudwatch/home?region=us-west-2#logEvent:group=/aws/codebuild/my-demo-project;stream=1a2b3c4d-5678-90ab-cdef-11111EXAMPLE", "groupName": "/aws/codebuild/my-demo-project" }, "arn": "arn:aws:codebuild:us-west-2:123456789012:build/my-demo-project:1a2b3c4d-5678-90ab-cdef-11111EXAMPLE" } }
如需詳細資訊,請參閱 AWS CLI 使用者指南中的停止建置 (Word)。 AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 StopBuild
。
-
下列程式碼範例示範如何使用 update-project
。
- AWS CLI
-
變更 AWS CodeBuild 建置專案的設定。
下列
update-project
範例會變更名為 CodeBuild 的指定 my-demo-project 建置專案設定。aws codebuild update-project --name
"my-demo-project"
\ --description"This project is updated"
\ --source "{\"type\": \"S3\",\"location\": \"codebuild-us-west-2-123456789012-input-bucket/my-source-2.zip\"}" \ --artifacts {"\"type\": \"S3\",\"location\": \"codebuild-us-west-2-123456789012-output-bucket-2\""} \ --environment "{\"type\": \"LINUX_CONTAINER\",\"image\": \"aws/codebuild/standard:1.0\",\"computeType\": \"BUILD_GENERAL1_MEDIUM\"}" \ --service-role"arn:aws:iam::123456789012:role/service-role/my-codebuild-service-role"
輸出會顯示更新的設定。
{ "project": { "arn": "arn:aws:codebuild:us-west-2:123456789012:project/my-demo-project", "environment": { "privilegedMode": false, "environmentVariables": [], "type": "LINUX_CONTAINER", "image": "aws/codebuild/standard:1.0", "computeType": "BUILD_GENERAL1_MEDIUM", "imagePullCredentialsType": "CODEBUILD" }, "queuedTimeoutInMinutes": 480, "description": "This project is updated", "artifacts": { "packaging": "NONE", "name": "my-demo-project", "type": "S3", "namespaceType": "NONE", "encryptionDisabled": false, "location": "codebuild-us-west-2-123456789012-output-bucket-2" }, "encryptionKey": "arn:aws:kms:us-west-2:123456789012:alias/aws/s3", "badge": { "badgeEnabled": false }, "serviceRole": "arn:aws:iam::123456789012:role/service-role/my-codebuild-service-role", "lastModified": 1556840545.967, "tags": [], "timeoutInMinutes": 60, "created": 1556839783.274, "name": "my-demo-project", "cache": { "type": "NO_CACHE" }, "source": { "type": "S3", "insecureSsl": false, "location": "codebuild-us-west-2-123456789012-input-bucket/my-source-2.zip" } } }
如需詳細資訊,請參閱 AWS CLI 使用者指南中的變更建置專案的設定 (Word) AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 UpdateProject
。
-
下列程式碼範例示範如何使用 update-report-group
。
- AWS CLI
-
更新 in AWS CodeBuild 中的報告群組。
下列
update-report-group
範例會將報告群組的匯出類型變更為 "NO_EXPORT"。aws codebuild update-report-group \ --arn
arn:aws:codebuild:<region-ID>:<user-ID>:report-group/cli-created-report-group
\ --export-config="exportConfigType=NO_EXPORT"輸出:
{ "reportGroup": { "arn": "arn:aws:codebuild:<region-ID>:<user-ID>:report-group/cli-created-report-group", "name": "cli-created-report-group", "type": "TEST", "exportConfig": { "exportConfigType": "NO_EXPORT" }, "created": 1602020686.009, "lastModified": 1602021033.454, "tags": [] } }
如需詳細資訊,請參閱 AWS CodeBuild 使用者指南中的使用報告群組。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 UpdateReportGroup
。
-
下列程式碼範例示範如何使用 update-webhook
。
- AWS CLI
-
更新 a AWS CodeBuild 專案的 Webhook
下列
update-webhook
範例會使用兩個篩選群組更新指定 CodeBuild 專案的 Webhook。--rotate-secret
參數指定每次程式碼變更觸發組建時, GitHub 都會輪換專案的秘密金鑰。第一個篩選群組指定在分支上建立、更新或重新開啟的提取請求,並且這些分支的 Git 參考名稱符合規則表達式^refs/heads/master$
,而標頭參考符合^refs/heads/myBranch$
。第二個篩選條件群組指定分支上的推送請求,其 Git 參考名稱與規則表達式 不相符^refs/heads/myBranch$
。aws codebuild update-webhook \ --project-name
Project2
\ --rotate-secret \ --filter-groups "[[{\"type\":\"EVENT\",\"pattern\":\"PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_REOPENED\"},{\"type\":\"HEAD_REF\",\"pattern\":\"^refs/heads/myBranch$\",\"excludeMatchedPattern\":true},{\"type\":\"BASE_REF\",\"pattern\":\"^refs/heads/master$\",\"excludeMatchedPattern\":true}],[{\"type\":\"EVENT\",\"pattern\":\"PUSH\"},{\"type\":\"HEAD_REF\",\"pattern\":\"^refs/heads/myBranch$\",\"excludeMatchedPattern\":true}]]"輸出:
{ "webhook": { "filterGroups": [ [ { "pattern": "PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, PULL_REQUEST_REOPENED", "type": "EVENT" }, { "excludeMatchedPattern": true, "pattern": "refs/heads/myBranch$", "type": "HEAD_REF" }, { "excludeMatchedPattern": true, "pattern": "refs/heads/master$", "type": "BASE_REF" } ], [ { "pattern": "PUSH", "type": "EVENT" }, { "excludeMatchedPattern": true, "pattern": "refs/heads/myBranch$", "type": "HEAD_REF" } ] ], "lastModifiedSecret": 1556312220.133 } }
如需詳細資訊,請參閱 AWS CLI 使用者指南中的變更建置專案的設定 (Word) AWS CodeBuild
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 UpdateWebhook
。
-