모니터링 CodePipeline 이벤트 - AWS CodePipeline

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

모니터링 CodePipeline 이벤트

자체 애플리케이션 software-as-a-service (SaaS) 애플리케이션 등에서 실시간 데이터 스트림을 제공하는 에서 CodePipeline EventBridge 이벤트를 모니터링할 수 있습니다. AWS 서비스 EventBridge 해당 데이터를 Amazon 심플 알림 AWS Lambda 서비스와 같은 대상으로 라우팅합니다. 이러한 이벤트는 AWS 리소스 변경을 설명하는 시스템 CloudWatch 이벤트의 스트림을 거의 실시간으로 제공하는 Amazon Events에 나타나는 이벤트와 동일합니다. 자세한 내용은 Amazon이란 무엇입니까 EventBridge? 를 참조하십시오. Amazon EventBridge 사용 설명서에서 확인할 수 있습니다.

참고

EventBridge Amazon은 이벤트를 관리하는 데 선호되는 방법입니다. Amazon CloudWatch EventBridge Events는 기본 서비스 및 API는 동일하지만 더 많은 기능을 EventBridge 제공합니다. CloudWatch 이벤트에서 변경하거나 각 콘솔에 변경 내용이 EventBridge 표시됩니다.

이벤트는 규칙으로 구성됩니다. 규칙은 다음을 선택하여 구성됩니다.

  • 이벤트 패턴. 각 규칙은 모니터링할 이벤트의 소스 및 유형, 이벤트 대상이 포함된 이벤트 패턴으로 표현됩니다. 이벤트를 모니터링하려면 모니터링 중인 서비스를 이벤트 소스로 사용하는 규칙 (예:) 을 생성합니다 CodePipeline. 예를 들어, 파이프라인, 단계 또는 작업의 상태가 변경될 때 규칙을 트리거하는 이벤트 CodePipeline 소스로 사용하는 이벤트 패턴을 포함하는 규칙을 생성할 수 있습니다.

  • 대상. 새 규칙은 선택한 서비스를 이벤트 대상으로 수신합니다. 알림을 보내거나, 상태 정보를 캡처하거나, 교정 작업을 수행하거나, 이벤트를 시작하거나, 기타 작업을 수행하도록 대상 서비스를 설정할 수 있습니다. 대상을 추가할 때는 선택한 대상 서비스를 EventBridge 호출할 수 있는 권한도 부여해야 합니다.

각 실행 상태 변경 이벤트 유형은 특정 메시지 내용이 포함된 알림을 내보냅니다. 여기에서:

  • version 항목은 이벤트의 버전 번호를 보여 줍니다.

  • 파이프라인 version 아래의 detail 항목은 파이프라인 구조 버전 번호를 보여 줍니다.

  • 파이프라인 execution-id 아래의 detail 항목은 상태 변경을 발생시킨 파이프라인 실행의 실행 ID를 보여 줍니다. AWS CodePipeline API 참조GetPipelineExecution API 직접 호출을 참조하세요.

  • pipeline-execution-attempt 항목은 특정 실행 ID에 대한 시도 또는 재시도 횟수를 보여줍니다.

CodePipeline 리소스 상태가 변경될 EventBridge 때마다 이벤트를 보고합니다 AWS 계정 . 이벤트는 다음 리소스를 at-least-once 기반으로 보장되어 생성됩니다.

  • 파이프라인 실행

  • 단계 실행

  • 작업 실행

는 위에서 설명한 이벤트 패턴 및 스키마를 EventBridge 사용하여 이벤트를 생성합니다. 개발자 도구 콘솔에서 구성한 알림을 통해 받는 이벤트와 같이 처리된 이벤트의 경우 이벤트 메시지에는 일부 변형이 있는 이벤트 패턴 필드가 포함됩니다. 예를 들어, detail-type 필드는 detailType으로 변환됩니다. 자세한 내용은 Amazon EventBridge API 참조의 PutEvents API 호출을 참조하십시오.

다음 예제는 에 대한 이벤트를 보여줍니다 CodePipeline. 가능한 경우, 각 예제는 처리된 이벤트에 대한 스키마와 함께 생성된 이벤트의 스키마를 보여줍니다.

세부 정보 유형

모니터링할 이벤트를 설정할 때 이벤트의 세부 유형을 선택할 수 있습니다.

다음의 상태가 변경될 때 보낼 알림을 구성할 수 있습니다.

  • 지정된 파이프라인 또는 모든 파이프라인. "detail-type": "CodePipeline Pipeline Execution State Change"를 사용하여 이를 제어합니다.

  • 지정된 파이프라인 또는 모든 파이프라인 내의 지정된 단계 또는 모든 단계. "detail-type": "CodePipeline Stage Execution State Change"를 사용하여 이를 제어합니다.

  • 지정된 파이프라인 또는 모든 파이프라인 내의 지정된 단계 또는 모든 단계에 속한 지정된 작업 또는 모든 작업. "detail-type": "CodePipeline Action Execution State Change"를 사용하여 이를 제어합니다.

참고

에서 발생하는 이벤트는 이벤트가 처리될 detailTypedetail-type 매개변수로 변환되는 매개변수를 EventBridge 포함합니다.

세부 정보 유형 State 설명
CodePipeline 파이프라인 실행 상태 변경 CANCELED 파이프라인 구조가 업데이트되지 않아 파이프라인 실행이 취소되었습니다.
FAILED 파이프라인 실행이 성공적으로 완료되지 않았습니다.
RESUMED 실패한 파이프라인 실행이 RetryStageExecution API 호출에 대한 응답으로 다시 시도되었습니다.
STARTED 파이프라인 실행이 현재 실행 중입니다.
중지됨(STOPPED) 중지 중인 프로세스가 완료되고 파이프라인 실행이 중지됩니다.
중지 중(STOPPING) 파이프라인 실행을 중지하고 대기하거나 중지하고 중단하라는 요청으로 인해 파이프라인 실행이 중지되는 중입니다.
SUCCEEDED 파이프라인 실행이 성공적으로 완료되었습니다.
SUPERSEDED

이 파이프라인 실행이 다음 단계가 완료되기를 기다리는 동안 새로운 파이프라인 실행이 진행되고 해당 파이프라인에서 계속되었습니다.

CodePipeline 스테이지 실행 상태 변경 CANCELED 파이프라인 구조가 업데이트되지 않아 단계가 취소되었습니다.
FAILED 단계가 성공적으로 완료되지 않았습니다.
RESUMED 실패한 단계가 RetryStageExecution API 호출에 대한 응답으로 다시 시도되었습니다.
STARTED 단계가 현재 실행 중입니다.
중지됨(STOPPED) 중지 중인 프로세스가 완료되고 단계 실행이 중지됩니다.
중지 중(STOPPING) 파이프라인 실행을 중지하고 대기하거나 중지하고 중단하라는 요청으로 인해 단계 실행이 중지되는 중입니다.
SUCCEEDED 단계가 성공적으로 완료되었습니다.
CodePipeline 액션 실행 상태 변경 ABANDONED 파이프라인 실행을 중지하고 중단하라는 요청으로 인해 작업이 중단됩니다.
CANCELED 파이프라인 구조가 업데이트되지 않아 작업이 취소되었습니다.
FAILED 승인 작업의 경우 FAILED 상태는 검토자가 작업을 거부했거나 잘못된 작업 구성으로 인해 작업이 실패했음을 의미합니다.
STARTED 작업이 현재 실행 중입니다.
SUCCEEDED 작업이 성공적으로 완료되었습니다.

파이프라인 수준 이벤트

파이프라인 수준 이벤트는 파이프라인 실행의 상태가 변경될 때 발생합니다.

파이프라인 STARTED 이벤트

파이프라인 실행이 시작되면 다음 내용이 포함된 알림을 보내는 이벤트를 내보냅니다. 이는 us-east-1 리전의 "myPipeline"이라는 파이프라인에 대한 예제입니다. id 필드는 이벤트 ID를 나타내고 account 필드는 파이프라인이 생성된 계정 ID를 나타냅니다.

Emitted event
{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Pipeline Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-24T22:03:07Z", "region": "us-east-1", "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:49:39.208Z", "execution-trigger": { "trigger-type": "StartPipelineExecution", "trigger-detail": "arn:aws:sts::123456789012:assumed-role/Admin/my-user" }, "state": "STARTED", "version": 1, "pipeline-execution-attempt": 1 } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Pipeline Execution State Change", "region": "us-east-1", "source": "aws.codepipeline", "time": "2021-06-24T00:44:50Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-east-1:123456789012:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:49:39.208Z", "execution-trigger": { "trigger-type": "StartPipelineExecution", "trigger-detail": "arn:aws:sts::123456789012:assumed-role/Admin/my-user" }, "state": "STARTED", "version": 1, "pipeline-execution-attempt": 1 }, "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "additionalAttributes": {} }

파이프라인 STOPPING 이벤트

파이프라인 실행이 중지되면 다음 내용이 포함된 알림을 보내는 이벤트를 내보냅니다. 이는 us-west-2 리전의 myPipeline이라는 파이프라인에 대한 예제입니다.

{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Pipeline Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-24T22:02:20Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:49:39.208Z", "state": "STOPPING", "version": 3, "pipeline-execution-attempt": 1 "stop-execution-comments": "Stopping the pipeline for an update" } }

파이프라인 SUCCEEDED 이벤트

파이프라인 실행이 성공하면 다음 내용이 포함된 알림을 보내는 이벤트를 내보냅니다. 이는 us-east-1 리전의 myPipeline이라는 파이프라인에 대한 예제입니다.

Emitted event
{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Pipeline Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-24T22:03:44Z", "region": "us-east-1", "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:49:39.208Z", "state": "SUCCEEDED", "version": 3, "pipeline-execution-attempt": 1 } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Pipeline Execution State Change", "region": "us-east-1", "source": "aws.codepipeline", "time": "2021-06-30T22:13:51Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-west-2:123456789012:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:49:39.208Z", "state": "SUCCEEDED", "version": 1, "pipeline-execution-attempt": 1 }, "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "additionalAttributes": {} }

파이프라인 SUCCEEDED(Git 태그를 사용한 예제)

파이프라인 실행에 재시도하여 성공한 단계가 있으면 다음 내용이 포함된 알림을 보내는 이벤트를 내보냅니다. 이 예제는execution-trigger가 Git 태그에 대해 구성된 eu-central-1 리전에서 myPipeline이라는 파이프라인에 대한 것입니다.

참고

execution-trigger 필드에는 파이프라인을 트리거한 이벤트의 종류에 따라 tag-name 또는 branch-name 둘 중 하나가 있습니다.

{ "version": "0", "id": "b128b002-09fd-4574-4eba-27152726c777", "detail-type": "CodePipeline Pipeline Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2023-10-26T13:50:53Z", "region": "eu-central-1", "resources": [ "arn:aws:codepipeline:eu-central-1:123456789012:BuildFromTag" ], "detail": { "pipeline": "BuildFromTag", "execution-id": "e17b5773-cc0d-4db2-9ad7-594c73888de8", "start-time": "2023-10-26T13:49:39.208Z", "execution-trigger": { "author-display-name": "Mary Major", "full-repository-name": "mmajor/sample-project", "provider-type": "GitLab", "author-email": "email_address", "commit-message": "Update file README.md", "author-date": "2023-08-16T21:08:08Z", "tag-name": "gitlab-v4.2.1", "commit-id": "commit_ID", "connection-arn": "arn:aws:codestar-connections:eu-central-1:123456789012:connection/0f5b706a-1a1d-46c5-86b6-f177321bcfb2", "author-id": "Mary Major" }, "state": "SUCCEEDED", "version": 32.0, "pipeline-execution-attempt": 1.0 } }

파이프라인 FAILED 이벤트

파이프라인 실행이 실패하면 다음 내용이 포함된 알림을 보내는 이벤트를 내보냅니다. 이는 us-west-2 리전의 "myPipeline"이라는 파이프라인에 대한 예제입니다.

Emitted event
{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Pipeline Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-31T18:55:43Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:49:39.208Z", "state": "FAILED", "version": 4, "pipeline-execution-attempt": 1 } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Pipeline Execution State Change", "region": "us-west-2", "source": "aws.codepipeline", "time": "2021-06-24T00:46:16Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-west-2:123456789012:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:49:39.208Z", "state": "FAILED", "version": 1, "pipeline-execution-attempt": 1 }, "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "additionalAttributes": { "failedActionCount": 1, "failedActions": [ { "action": "Deploy", "additionalInformation": "Deployment <ID> failed" } ], "failedStage": "Deploy" }

파이프라인 FAILED(Git 태그를 사용한 예제)

소스 단계에서 실패하지 않는 한 트리거가 포함된 파이프라인 구성의 경우 다음 내용이 포함된 알림을 보내는 이벤트가 발생합니다. 이 예제는execution-trigger가 Git 태그에 대해 구성된 eu-central-1 리전에서 myPipeline이라는 파이프라인에 대한 것입니다.

참고

execution-trigger 필드에는 파이프라인을 트리거한 이벤트의 종류에 따라 tag-name 또는 branch-name 둘 중 하나가 있습니다.

Emitted event
{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Pipeline Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-31T18:55:43Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:49:39.208Z", "execution-trigger": { "author-display-name": "Mary Major", "full-repository-name": "mmajor/sample-project", "provider-type": "GitLab", "author-email": "email_address", "commit-message": "Update file README.md", "author-date": "2023-08-16T21:08:08Z", "tag-name": "gitlab-v4.2.1", "commit-id": "commit_ID", "connection-arn": "arn:aws:codestar-connections:eu-central-1:123456789012:connection/0f5b706a-1a1d-46c5-86b6-f177321bcfb2", "author-id": "Mary Major" }, "state": "FAILED", "version": 4, "pipeline-execution-attempt": 1 } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Pipeline Execution State Change", "region": "us-west-2", "source": "aws.codepipeline", "time": "2021-06-24T00:46:16Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-west-2:123456789012:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:49:39.208Z", "execution-trigger": { "author-display-name": "Mary Major", "full-repository-name": "mmajor/sample-project", "provider-type": "GitLab", "author-email": "email_address", "commit-message": "Update file README.md", "author-date": "2023-08-16T21:08:08Z", "tag-name": "gitlab-v4.2.1", "commit-id": "commit_ID", "connection-arn": "arn:aws:codestar-connections:eu-central-1:123456789012:connection/0f5b706a-1a1d-46c5-86b6-f177321bcfb2", "author-id": "Mary Major" }, "state": "FAILED", "version": 1, "pipeline-execution-attempt": 1 }, "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "additionalAttributes": { "failedActionCount": 1, "failedActions": [ { "action": "Deploy", "additionalInformation": "Deployment <ID> failed" } ], "failedStage": "Deploy" }

단계 수준 이벤트

단계 수준 이벤트는 단계 실행의 상태가 변경될 때 발생합니다.

단계 STARTED 이벤트

단계 실행이 시작되면 다음 내용이 포함된 알림을 보내는 이벤트를 내보냅니다. 이는 us-east-1 리전의 "myPipeline"이라는 파이프라인의 단계 Prod에 대한 예제입니다.

Emitted event
{ "version": "0", "id": 01234567-EXAMPLE, "detail-type": "CodePipeline Stage Execution State Change", "source": "aws.codepipeline", "account": 123456789012, "time": "2020-01-24T22:03:07Z", "region": "us-east-1", "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "version": "1", "execution-id": 12345678-1234-5678-abcd-12345678abcd, "start-time": "2023-10-26T13:49:39.208Z", "stage": "Prod", "state": "STARTED", "pipeline-execution-attempt": 1 } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Stage Execution State Change", "region": "us-east-1", "source": "aws.codepipeline", "time": "2021-06-24T00:45:40Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-west-2:123456789012:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:49:39.208Z", "stage": "Source", "state": "STARTED", "version": 1, "pipeline-execution-attempt": 0 }, "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "additionalAttributes": { "sourceActions": [ { "sourceActionName": "Source", "sourceActionProvider": "CodeCommit", "sourceActionVariables": { "BranchName": "main", "CommitId": "<ID>", "RepositoryName": "my-repo" } } ] } }

단계 STOPPING 이벤트

단계 실행이 중지되면 다음 내용이 포함된 알림을 보내는 이벤트를 내보냅니다. 이는 us-west-2 리전의 myPipeline이라는 파이프라인의 단계 Deploy에 대한 예제입니다.

{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Stage Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-24T22:02:20Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:49:39.208Z", "stage": "Deploy", "state": "STOPPING", "version": 3, "pipeline-execution-attempt": 1 } }

단계 STOPPED 이벤트

단계 실행이 중단되면 다음 내용이 포함된 알림을 보내는 이벤트를 내보냅니다. 이는 us-west-2 리전의 myPipeline이라는 파이프라인의 단계 Deploy에 대한 예제입니다.

{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Stage Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-31T18:21:39Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:49:39.208Z", "stage": "Deploy", "state": "STOPPED", "version": 3, "pipeline-execution-attempt": 1 } }

단계 재시도 이벤트 이후 Stage RESUMED

단계 실행이 재개되고 재시도된 단계가 있으면 다음 내용이 포함된 알림을 보내는 이벤트를 내보냅니다.

단계가 재시도되면 예제와 같이 stage-last-retry-attempt-time 필드가 표시됩니다. 재시도가 수행된 경우 모든 단계 이벤트에 필드가 표시됩니다.

참고

단계가 재시도되면 모든 후속 단계 이벤트에 stage-last-retry-attempt-time 필드가 표시됩니다.

{ "version": "0", "id": "38656bcd-a798-5f92-c738-02a71be484e1", "detail-type": "CodePipeline Stage Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2023-10-26T14:14:56Z", "region": "eu-central-1", "resources": [ "arn:aws:codepipeline:eu-central-1:123456789012:BuildFromTag" ], "detail": { "pipeline": "BuildFromTag", "execution-id": "05dafb6a-5a56-4951-a858-968795364846", "stage-last-retry-attempt-time": "2023-10-26T14:14:56.305Z", "stage": "Build", "state": "RESUMED", "version": 32.0, "pipeline-execution-attempt": 2.0 } }

작업 수준 이벤트

작업 수준 이벤트는 작업 실행의 상태가 변경될 때 발생합니다.

작업 STARTED 이벤트

작업 실행이 시작되면 다음 내용이 포함된 알림을 보내는 이벤트를 내보냅니다. 이는 us-east-1 리전의 myPipeline이라는 파이프라인의 배포 작업 myAction에 대한 예제입니다.

Emitted event
{ "version": "0", "id": 01234567-EXAMPLE, "detail-type": "CodePipeline Action Execution State Change", "source": "aws.codepipeline", "account": 123456789012, "time": "2020-01-24T22:03:07Z", "region": "us-east-1", "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": 12345678-1234-5678-abcd-12345678abcd, "start-time": "2023-10-26T13:51:09.981Z", "stage": "Prod", "action-execution-id": "47f821c5-a902-44b2-ae61-b878d31ecd21", "action": "myAction", "state": "STARTED", "type": { "owner": "AWS", "category": "Deploy", "provider": "CodeDeploy", "version": 1 }, "pipeline-execution-attempt": 1 "input-artifacts": [ { "name": "SourceArtifact", "s3location": { "bucket": "codepipeline-us-east-1-BUCKETEXAMPLE", "key": "myPipeline/SourceArti/KEYEXAMPLE" } } ] } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Action Execution State Change", "region": "us-west-2", "source": "aws.codepipeline", "time": "2021-06-24T00:45:44Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-west-2:123456789012:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:51:09.981Z", "stage": "Deploy", "action-execution-id": "47f821c5-a902-44b2-ae61-b878d31ecd21", "action": "Deploy", "input-artifacts": [ { "name": "SourceArtifact", "s3location": { "bucket": "codepipeline-us-east-1-EXAMPLE", "key": "myPipeline/SourceArti/EXAMPLE" } } ], "state": "STARTED", "region": "us-east-1", "type": { "owner": "AWS", "provider": "CodeDeploy", "category": "Deploy", "version": "1" }, "version": 1, "pipeline-execution-attempt": 1 }, "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "additionalAttributes": {} }

작업 SUCCEEDED 이벤트

작업 실행이 성공하면 다음 내용이 포함된 알림을 보내는 이벤트를 내보냅니다. 이는 us-west-2 리전의 "myPipeline"이라는 파이프라인의 소스 작업 "Source"에 대한 예제입니다. 이 이벤트 유형에는 두 개의 다른 region 필드가 있습니다. 이벤트 region 필드는 파이프라인 이벤트의 리전을 지정합니다. detail 섹션 아래의 region 필드는 작업의 리전을 지정합니다.

Emitted event
{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Action Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-24T22:03:11Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:51:09.981Z", "stage": "Source", "execution-result": { "external-execution-url": "https://us-west-2.console.aws.amazon.com/codecommit/home#/repository/my-repo/commit/8cf40f2EXAMPLE", "external-execution-summary": "Added LICENSE.txt", "external-execution-id": "8cf40fEXAMPLE" }, "output-artifacts": [ { "name": "SourceArtifact", "s3location": { "bucket": "codepipeline-us-west-2-BUCKETEXAMPLE", "key": "myPipeline/SourceArti/KEYEXAMPLE" } } ], "action-execution-id": "47f821c5-a902-44b2-ae61-b878d31ecd21", "action": "Source", "state": "SUCCEEDED", "region": "us-west-2", "type": { "owner": "AWS", "provider": "CodeCommit", "category": "Source", "version": "1" }, "version": 3, "pipeline-execution-attempt": 1 } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Action Execution State Change", "region": "us-west-2", "source": "aws.codepipeline", "time": "2021-06-24T00:45:44Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-west-2:ACCOUNT:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "arn:aws:codepipeline:us-west-2:123456789012:myPipeline", "start-time": "2023-10-26T13:51:09.981Z", "stage": "Source", "execution-result": { "external-execution-url": "https://us-west-2.console.aws.amazon.com/codecommit/home#/repository/my-repo/commit/8cf40f2EXAMPLE", "external-execution-summary": "Edited index.html", "external-execution-id": "36ab3ab7EXAMPLE" }, "output-artifacts": [ { "name": "SourceArtifact", "s3location": { "bucket": "codepipeline-us-west-2-EXAMPLE", "key": "myPipeline/SourceArti/EXAMPLE" } } ], "action-execution-id": "47f821c5-a902-44b2-ae61-b878d31ecd21", "action": "Source", "state": "SUCCEEDED", "region": "us-west-2", "type": { "owner": "AWS", "provider": "CodeCommit", "category": "Source", "version": "1" }, "version": 1, "pipeline-execution-attempt": 1 }, "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "additionalAttributes": {} }

작업 FAILED 이벤트

작업 실행이 실패하면 다음 내용이 포함된 알림을 보내는 이벤트를 내보냅니다. 이는 us-west-2 리전의 "myPipeline"이라는 파이프라인의 작업 "Deploy"에 대한 예제입니다.

Emitted event
{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Action Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-31T18:55:43Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "start-time": "2023-10-26T13:51:09.981Z", "stage": "Deploy", "execution-result": { "external-execution-url": "https://us-west-2.console.aws.amazon.com/codedeploy/home?#/deployments/<ID>", "external-execution-summary": "Deployment <ID> failed", "external-execution-id": "<ID>", "error-code": "JobFailed" }, "action-execution-id": "47f821c5-a902-44b2-ae61-b878d31ecd21", "action": "Deploy", "state": "FAILED", "region": "us-west-2", "type": { "owner": "AWS", "provider": "CodeDeploy", "category": "Deploy", "version": "1" }, "version": 4, "pipeline-execution-attempt": 1 } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Action Execution State Change", "region": "us-west-2", "source": "aws.codepipeline", "time": "2021-06-24T00:46:16Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-west-2:123456789012:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "stage": "Deploy", "execution-result": { "external-execution-url": "https://console.aws.amazon.com/codedeploy/home?region=us-west-2#/deployments/<ID>", "external-execution-summary": "Deployment <ID> failed", "external-execution-id": "<ID>", "error-code": "JobFailed" }, "action-execution-id": "47f821c5-a902-44b2-ae61-b878d31ecd21", "action": "Deploy", "state": "FAILED", "region": "us-west-2", "type": { "owner": "AWS", "provider": "CodeDeploy", "category": "Deploy", "version": "1" }, "version": 13, "pipeline-execution-attempt": 1 }, "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "additionalAttributes": { "additionalInformation": "Deployment <ID> failed" } }

작업 ABANDONED 이벤트

작업 실행이 중단되면 다음 내용이 포함된 알림을 보내는 이벤트를 내보냅니다. 이는 us-west-2 리전의 "myPipeline"이라는 파이프라인의 작업 "Deploy"에 대한 예제입니다.

{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Action Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-31T18:21:39Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "stage": "Deploy", "action-execution-id": "47f821c5-a902-44b2-ae61-b878d31ecd21", "action": "Deploy", "state": "ABANDONED", "region": "us-west-2", "type": { "owner": "AWS", "provider": "CodeDeploy", "category": "Deploy", "version": "1" }, "version": 3, "pipeline-execution-attempt": 1 } }

파이프라인 이벤트에 알림을 보내는 규칙 생성

규칙은 특정 이벤트를 감시한 다음 선택한 AWS 대상으로 라우팅합니다. 다른 AWS 작업이 발생할 때 자동으로 AWS 작업을 수행하는 규칙 또는 설정된 일정에 따라 정기적으로 AWS 작업을 수행하는 규칙을 만들 수 있습니다.

파이프라인 상태 변경 시 알림 보내기(콘솔)

이 단계에서는 EventBridge 콘솔을 사용하여 변경 사항에 대한 알림을 보내는 규칙을 만드는 방법을 보여줍니다 CodePipeline.

Amazon S3 소스로 파이프라인을 대상으로 하는 EventBridge 규칙을 생성하려면
  1. https://console.aws.amazon.com/events/ 에서 아마존 EventBridge 콘솔을 엽니다.

  2. 탐색 창에서 규칙을 선택합니다. 기본 버스를 선택된 상태로 두거나 이벤트 버스를 선택하세요. 규칙 생성을 선택합니다.

  3. 이름에 역할의 이름을 입력합니다.

  4. 규칙 유형에서 이벤트 패턴이 있는 규칙을 선택합니다. 다음을 선택합니다.

  5. 이벤트 패턴에서 AWS 서비스를 선택합니다.

  6. [Event Type] 드롭다운 목록에서 알림의 상태 변경 수준을 선택합니다.

    • 파이프라인 수준 이벤트에 적용되는 규칙을 보려면 CodePipeline파이프라인 실행 상태 변경을 선택하십시오.

    • 단계 수준 이벤트에 적용되는 규칙을 보려면 [단계 실행 상태 변경] 을 선택합니다CodePipeline.

    • 작업 수준 이벤트에 적용되는 규칙을 보려면 [CodePipeline작업 실행 상태 변경] 을 선택합니다.

  7. 규칙을 적용할 상태 변경을 지정합니다.

    • 모든 상태 변경에 적용되는 규칙의 경우 [Any state]를 선택합니다.

    • 일부 상태 변경에만 적용되는 규칙의 경우 [Specific state(s)]를 선택한 후 목록에서 상태 값을 한 개 이상 선택합니다.

  8. 선택기에서 허용하는 것보다 더 자세한 이벤트 패턴의 경우 이벤트 패턴 창의 패턴 편집 옵션을 사용하여 이벤트 패턴을 JSON 형식으로 지정할 수도 있습니다.

    참고

    달리 지정하지 않으면 모든 파이프라인/단계/작업 및 상태에 대한 이벤트 패턴이 생성됩니다.

    더 세부적인 이벤트 패턴의 경우 다음 이벤트 패턴 예제를 복사하여 이벤트 패턴 창에 붙여넣으면 됩니다.

    • 다음 이벤트 패턴 샘플을 사용하면 모든 파이프라인에서 실패한 배포 및 빌드 작업을 캡처합니다.

      { "source": [ "aws.codepipeline" ], "detail-type": [ "CodePipeline Action Execution State Change" ], "detail": { "state": [ "FAILED" ], "type": { "category": ["Deploy", "Build"] } } }
    • 다음 이벤트 패턴 샘플을 사용하면 모든 파이프라인에서 거부되었거나 실패한 모든 승인 작업을 캡처합니다.

      { "source": [ "aws.codepipeline" ], "detail-type": [ "CodePipeline Action Execution State Change" ], "detail": { "state": [ "FAILED" ], "type": { "category": ["Approval"] } } }
    • 다음 이벤트 패턴 샘플을 사용하면 지정된 파이프라인에서 모든 이벤트를 캡처합니다.

      { "source": [ "aws.codepipeline" ], "detail-type": [ "CodePipeline Pipeline Execution State Change", "CodePipeline Action Execution State Change", "CodePipeline Stage Execution State Change" ], "detail": { "pipeline": ["myPipeline", "my2ndPipeline"] } }
  9. 다음을 선택합니다.

  10. 대상 유형에서 AWS 서비스를 선택합니다.

  11. 대상 선택에서 을 선택합니다. CodePipeline Pipeline ARN에서 이 규칙에 의해 시작되는 파이프라인의 파이프라인 ARN을 입력합니다.

    참고

    파이프라인 ARN을 확인하려면 get-pipeline 명령을 실행합니다. 출력에 파이프라인 ARN이 나타납니다. ARN의 형식은 다음과 같습니다.

    arn:aws:codepipeline:region:account:pipeline-name

    파이프라인 ARN 샘플:

    arn:aws:code 파이프라인:us-east- 2:80398 예제: MyFirstPipeline

  12. 규칙과 연결된 대상을 호출할 EventBridge 권한을 부여하는 IAM 서비스 역할을 만들거나 지정하려면 (이 경우 대상은 다음과 같습니다): EventBridge CodePipeline

    • 이 특정 리소스에 대한 새 역할 생성을 선택하여 파이프라인 실행을 시작할 EventBridge 권한을 부여하는 서비스 역할을 생성합니다.

    • 기존 역할 사용을 선택하여 파이프라인 실행을 시작할 EventBridge 권한을 부여하는 서비스 역할을 입력합니다.

  13. 다음을 선택합니다.

  14. 태그 페이지에서 다음을 선택합니다.

  15. 검토 및 생성 페이지에서 규칙 구성을 검토합니다. 규칙이 만족스러우면 규칙 생성(Create rule)을 선택하세요.

파이프라인 상태 변경 시 알림 보내기(CLI)

이 단계는 CLI를 사용하여 변경 사항에 대한 알림을 보내는 CloudWatch 이벤트 규칙을 생성하는 방법을 보여줍니다. CodePipeline

를 사용하여 규칙을 AWS CLI 생성하려면 다음을 지정하여 put-rule 명령을 호출합니다.

  • 만들려는 규칙을 고유하게 식별하는 이름. 이 이름은 CodePipeline AWS 계정과 연계하여 생성한 모든 파이프라인에서 고유해야 합니다.

  • 소스의 이벤트 패턴 및 규칙에서 사용하는 세부 정보 필드. 자세한 내용은 Amazon EventBridge 및 이벤트 패턴을 참조하십시오.

이벤트 CodePipeline 소스로 사용하여 EventBridge 규칙을 생성하려면
  1. put-rule 명령을 호출하여 이벤트 패턴을 지정하는 규칙을 만듭니다. (유효한 상태는 앞의 표 참조)

    다음은 이름이 “MyPipeline”인 파이프라인에 대한 파이프라인 실행이 실패할 경우 CloudWatch 이벤트를 “MyPipelineStateChanges” 발생시키는 규칙을 생성하는 데 사용되는 --event-pattern 샘플 명령입니다.

    aws events put-rule --name "MyPipelineStateChanges" --event-pattern "{\"source\":[\"aws.codepipeline\"],\"detail-type\":[\"CodePipeline Pipeline Execution State Change\"],\"detail\":{\"pipeline\":[\"myPipeline\"],\"state\":[\"FAILED\"]}}"
  2. put-targets 명령을 호출하고 다음 파라미터를 포함합니다.

    • --rule 파라미터는 put-rule을 사용하여 생성한 rule_name에 사용됩니다.

    • --targets 파라미터는 대상 목록에 있는 대상의 목록 Id 및 Amazon SNS 주제의 ARN에 사용됩니다.

    다음 예제 명령은 MyPipelineStateChanges이라는 규칙에 대해 대상 Id가 숫자 1로 구성됨을 지정하며, 규칙의 대상 목록에서 1로 대상 1로 표시됩니다. 이 예제 명령은 또한 Amazon SNS 주제에 대한 예제 ARN을 지정합니다.

    aws events put-targets --rule MyPipelineStateChanges --targets Id=1,Arn=arn:aws:sns:us-west-2:11111EXAMPLE:MyNotificationTopic
  3. 지정된 대상 서비스를 EventBridge 사용하여 알림을 호출할 수 있는 권한을 추가합니다. 자세한 내용은 Amazon의 리소스 기반 정책 사용을 참조하십시오. EventBridge