어노테이션 API
어노테이션은 빌드의 작업 실행 중 에이전트가 업로드하는 Markdown 스니펫이에요. 어노테이션은 작업 안에서 buildkite-agent annotate 명령으로 생성돼요.
출처: 문서
본문
어노테이션 데이터 모델
id |
어노테이션의 ID |
|---|---|
context |
빌드를 어노테이션할 때 지정한 "context". 각 빌드에는 주어진 context 값을 가진 어노테이션이 하나만 있을 수 있어요. |
style |
어노테이션의 스타일. success, info, warning 또는 error일 수 있어요. |
scope |
어노테이션의 범위. build 또는 job. |
job_id |
어노테이션과 연관된 작업의 ID, 빌드 범위 어노테이션은 null |
priority |
어노테이션의 우선순위(1~10). 값이 높을수록 먼저 표시돼요. 기본값은 3. |
body_html |
어노테이션 본문의 렌더링된 HTML. List annotations for a build 엔드포인트는 요청에 omit_body=true가 포함되면 이 필드를 생략해요. |
created_at |
어노테이션이 처음 생성된 시점 |
updated_at |
어노테이션이 마지막으로 추가되거나 교체된 시점 |
빌드의 어노테이션 목록 조회
빌드의 어노테이션의 페이지네이션된 목록을 반환해요.
curl -H "Authorization: Bearer ***" \
-X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds/{build.number}/annotations"
📘 이 URL은 빌드 ID(예:
01908131-7d9f-495e-a17b-80ed31276810)가 아니라 빌드 번호(예:3)를 사용해야 한다는 점을 기억해요. 이 두 개념의 차이에 대해 더 알아보려면 Build number vs build ID를 참고해요.
[
{
"id": "de0d4ab5-6360-467a-a34b-e5ef5db5320d",
"context": "default",
"style": "info",
"scope": "build",
"job_id": null,
"priority": 3,
"body_html": "<h1>My Markdown Heading</h1>\n<img src=\"artifact://indy.png\" alt=\"Belongs in a museum\" height=250 />",
"created_at": "2019-04-09T18:07:15.775Z",
"updated_at": "2019-08-06T20:58:49.396Z"
},
{
"id": "5b3ceff6-78cb-4fe9-88ae-51be5f145977",
"context": "coverage",
"style": "info",
"scope": "build",
"job_id": null,
"priority": 3,
"body_html": "Read the <a href=\"artifact://coverage/index.html\">uploaded coverage report</a>",
"created_at": "2019-04-09T18:07:16.320Z",
"updated_at": "2019-04-09T18:07:16.320Z"
}
]
선택적 쿼리 문자열 매개변수:
scope |
범위로 어노테이션을 필터링. build 값은 빌드 범위 어노테이션을 반환하며 기본값이에요. job 값은 작업 범위 어노테이션을 반환해요. all 값은 둘 다 반환해요. 예: scope=all |
|---|---|
omit_body |
true로 설정하면 응답의 각 어노테이션에서 body_html 필드를 생략해요. 이 매개변수를 사용해 응답 본문 없이 어노테이션 메타데이터를 가져와요. 기본값은 false. 예: omit_body=true |
필수 범위: read_builds
성공 응답: 200 OK
빌드에 어노테이션 생성
빌드에 어노테이션을 생성해요.
curl -H "Authorization: Bearer ***" \
-X POST "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds/{build.number}/annotations" \
-H "Content-Type: application/json" \
-d '{
"body": "Hello world!",
"style": "info",
"priority": 5,
"context": "greeting"
}'
📘 이 URL은 빌드 ID 가 아니라 빌드 번호 를 사용해야 한다는 점을 기억해요. 이 두 개념의 차이에 대해 더 알아보려면 Build number vs build ID를 참고해요.
{
"id": "018b8d10-6b5b-4df2-b0ff-dfa2af566050",
"context": "greeting",
"style": "info",
"scope": "build",
"job_id": null,
"priority": 5,
"body_html": "<p>Hello world!</p>\n",
"created_at": "2023-11-01T22:45:45.435Z",
"updated_at": "2023-11-01T22:45:45.435Z"
}
필수 요청 본문 속성:
body |
HTML 또는 Markdown으로 된 어노테이션 본문. 예: "My annotation here" |
|---|
선택적 요청 본문 속성:
style |
어노테이션의 스타일. success, info, warning 또는 error일 수 있어요. 예: "info" |
|---|---|
priority |
어노테이션의 우선순위(1~10). 우선순위가 10인 어노테이션이 먼저, 1인 어노테이션이 마지막에 표시돼요. 이 옵션을 지정하지 않으면 어노테이션은 기본 우선순위 3을 가져요. 예: 5 |
context |
빌드에서 어노테이션을 식별하는 문자열 값. 기존 어노테이션에 추가할 때 유용해요. 각 빌드에는 주어진 context 값을 가진 어노테이션이 하나만 있을 수 있어요. 예: "coverage" |
append |
주어진 body를 같은 context의 어노테이션에 추가할지 여부. 예: true |
필수 범위: write_builds
성공 응답: 201 Created
빌드의 어노테이션 삭제
빌드에 있는 어노테이션을 삭제해요.
curl -H "Authorization: Bearer ***" \
-X DELETE "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds/{build.number}/annotations/{annotation.uuid}"
필수 범위: write_builds
성공 응답: 204 No Content
작업의 어노테이션 목록 조회
작업의 어노테이션의 페이지네이션된 목록을 반환해요.
curl -H "Authorization: Bearer ***" \
-X GET "https://api.buildkite.com/v2/organizations/{org.slug}/jobs/{job.id}/annotations"
파이프라인 slug와 빌드 번호가 있다면 빌드 범위 경로를 사용할 수도 있어요.
curl -H "Authorization: Bearer ***" \
-X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds/{build.number}/jobs/{job.id}/annotations"
[
{
"id": "a7c5b1d2-4f3e-4a1b-9c8d-6e2f1a3b4c5d",
"context": "test-results",
"style": "success",
"scope": "job",
"job_id": "01234567-89ab-4cde-8f01-23456789abcd",
"priority": 3,
"body_html": "<p>All 42 tests passed</p>\n",
"created_at": "2024-01-15T10:30:00.000Z",
"updated_at": "2024-01-15T10:30:00.000Z"
}
]
필수 범위: read_builds
성공 응답: 200 OK
작업에 어노테이션 생성
빌드의 특정 작업에 범위가 한정된 어노테이션을 생성해요. 작업 범위 어노테이션은 빌드 범위 어노테이션과 동일한 매개변수를 사용해요. 다만 scope는 자동으로 job으로 설정돼요.
curl -H "Authorization: Bearer ***" \
-X POST "https://api.buildkite.com/v2/organizations/{org.slug}/jobs/{job.id}/annotations" \
-H "Content-Type: application/json" \
-d '{
"body": "Test results: 42 passed",
"style": "success",
"context": "test-results"
}'
파이프라인 slug와 빌드 번호가 있다면 빌드 범위 경로를 사용할 수도 있어요.
curl -H "Authorization: Bearer ***" \
-X POST "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds/{build.number}/jobs/{job.id}/annotations" \
-H "Content-Type: application/json" \
-d '{
"body": "Test results: 42 passed",
"style": "success",
"context": "test-results"
}'
{
"id": "a7c5b1d2-4f3e-4a1b-9c8d-6e2f1a3b4c5d",
"context": "test-results",
"style": "success",
"scope": "job",
"job_id": "01234567-89ab-4cde-8f01-23456789abcd",
"priority": 3,
"body_html": "<p>Test results: 42 passed</p>\n",
"created_at": "2024-01-15T10:30:00.000Z",
"updated_at": "2024-01-15T10:30:00.000Z"
}
필수 요청 본문 속성:
body |
HTML 또는 Markdown으로 된 어노테이션 본문. 예: "My annotation here" |
|---|
선택적 요청 본문 속성:
style |
어노테이션의 스타일. success, info, warning 또는 error일 수 있어요. 예: "info" |
|---|---|
priority |
어노테이션의 우선순위(1~10). 우선순위가 10인 어노테이션이 먼저, 1인 어노테이션이 마지막에 표시돼요. 이 옵션을 지정하지 않으면 어노테이션은 기본 우선순위 3을 가져요. 예: 5 |
context |
작업에서 어노테이션을 식별하는 문자열 값. 기존 어노테이션에 추가할 때 유용해요. 각 작업에는 주어진 context 값을 가진 어노테이션이 하나만 있을 수 있어요. 예: "coverage" |
append |
주어진 body를 같은 context의 어노테이션에 추가할지 여부. 예: true |
필수 범위: write_builds
성공 응답: 201 Created
작업의 어노테이션 삭제
작업에 있는 어노테이션을 삭제해요.
curl -H "Authorization: Bearer ***" \
-X DELETE "https://api.buildkite.com/v2/organizations/{org.slug}/jobs/{job.id}/annotations/{annotation.uuid}"
파이프라인 slug와 빌드 번호가 있다면 빌드 범위 경로를 사용할 수도 있어요.
curl -H "Authorization: Bearer ***" \
-X DELETE "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds/{build.number}/jobs/{job.id}/annotations/{annotation.uuid}"
필수 범위: write_builds
성공 응답: 204 No Content
더 알아보기 (Learn more)
어노테이션 API는 빌드나 작업에 Markdown/HTML 어노테이션을 올리고 조회·삭제할 수 있게 해줘요. 에이전트의 buildkite-agent annotate 명령으로 생성된 어노테이션을 read_builds 범위로 목록을, write_builds 범위로 생성·삭제를 할 수 있어요. context로 어노테이션을 식별해 기존 것에 추가(append)할 수 있고, style(success/info/warning/error)·priority(1~10)·scope(build/job)로 표현을 조정해 보세요. 빌드 경로를 쓸 땐 빌드 ID가 아닌 빌드 번호를 사용해야 한다는 점을 기억해요.