Annotation
Buildkite Pipelines의 annotation 기능은 빌드 페이지(_빌드 annotation_이라고 불러요)에 커스텀 콘텐츠를 추가하게 해줘요. 파이프라인 스텝에서 만들거나 REST·GraphQL API로 만들 수 있죠.
빌드 annotation은 빌드 페이지의 메인 Annotations 탭에 나타나요. 이 인터페이스를 탐색하는 방법에 대해서는 Build page를 참고하세요.
개별 잡에도 annotation을 추가할 수 있어요(_잡 스코프 annotation_이라고 불러요). 관련 파이프라인 스텝에서 만들거나 REST·GraphQL API로 만들 수 있죠.
annotation을 추가하면 다양한 용도로 쓸모가 있어요. 예컨대 빌드의 잡 결과를 요약해 읽기 쉽게 만들거나, 실패한 스텝의 잡 실행에서 핵심 실패 구성 요소를 제시하는 식이에요.
출처: 문서
본문
빌드 annotation 만들기
빌드 annotation은 빌드의 잡 안에서 만들 수 있고, Buildkite의 REST API와 GraphQL API로 외부에서도 만들 수 있어요.
만들 수 있는 annotation 수에는 제한이 없지만, 각 annotation 본문의 최대 크기는 1MiB예요. 크기는 바이트로 측정되고, 기반 데이터 인코딩을 반영해요. 구체적인 인코딩에 따라 크기 계산이 달라질 수 있죠. 예컨대 UTF-8 인코딩이면 어떤 문자는 글자당 최대 4바이트로 인코딩될 수 있어요.
빌드의 잡 안에서 만들기
빌드의 잡 안에서 annotation을 만들려면, 그 잡의 스텝 정의 안에서 buildkite-agent annotate 명령을 쓰세요.
예컨대 이런 스텝은:
steps:
- label: "\:writing_hand\: Example"
command: |
cat << 'EOF' | buildkite-agent annotate --style "info" --context "agent-cli-example"
### Example annotation
This was created from within a build's job.
EOF
빌드 페이지의 메인 Annotations 탭에 이런 annotation을 만들어요.

이런 식으로 annotation을 만드는 게 가장 흔한 접근이에요. 이 스텝들은 여러분의 파이프라인 빌드의 일부로 실행되거든요.
이 Buildkite agent 명령으로 annotation을 만드는 방법에 대해서는 Formatting annotations에서 더 알아보세요.
REST API로 외부에서 만들기
REST API로 빌드 annotation을 만들려면 다음 예시 curl 명령을 실행하세요.
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": "### Example annotation\n\nThis was created using the REST API.",
"style": "info",
"context": "rest-api-example"
}'
각 항목의 의미는 이렇습니다.
-
$TOKEN은 요청이 Buildkite에서 접근해야 하는 관련 Organization과 REST API Scopes로 스코프된 API 액세스 토큰이에요. -
{org.slug}는 이렇게 얻을 수 있어요:-
Buildkite 조직의 전역 내비게이션에서 Pipelines에 접근한 뒤, Buildkite URL 끝부분에서 얻어요.
-
List organizations REST API 쿼리를 실행해 응답의
slug에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations"
-
-
{pipeline.slug}는 이렇게 얻을 수 있어요:-
전역 내비게이션에서 Pipelines > 여러분의 특정 파이프라인에 접근한 뒤, Buildkite URL 끝부분에서 얻어요.
-
List pipelines REST API 쿼리를 실행해 응답의
slug에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines"
-
-
{build.number}는 이렇게 얻을 수 있어요:-
전역 내비게이션에서 Pipelines > 여러분의 특정 파이프라인 > 여러분의 특정 파이프라인 빌드에 접근한 뒤, Buildkite URL에서
builds/뒤의 숫자에서 얻어요. -
List builds for a pipeline REST API 쿼리를 실행해 응답의
number에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds"
-
-
body,style,context필드의 사용법에 대해서는,buildkite-agent annotate명령이 이 필드들을 쓰는 방식과 연관된 상세를 Formatting annotations에서 참고하세요.
GraphQL API로 외부에서 만들기
GraphQL API로 빌드 annotation을 만들려면 다음 예시 mutation을 실행하세요.
mutation {
buildAnnotate(input: {
buildID: "build-id",
body: "### Example annotation\n\nThis was created using the GraphQL API.",
style: INFO,
context: "graphql-api-example"
}) {
annotation {
uuid
style
context
body {
html
}
}
}
}
각 항목의 의미는 이렇습니다.
-
buildID(필수)는 Get builds GraphQL API 쿼리를 실행해, 응답의 빌드 번호(number값으로 지정돼요)와 연관된id에서 얻을 수 있어요. 예를 들면:query GetBuilds { pipeline(slug: "organization-slug/pipeline-slug") { builds(first: 10) { edges { node { id number url } } } } }Tip: Buildkite 인터페이스에서 Pipelines > 여러분의 특정 파이프라인 > 여러분의 특정 파이프라인 빌드로 접근한 뒤, Buildkite URL에서
builds/뒤의 빌드 번호를 확인해 빌드 번호를 annotation과 연관 지을 수 있어요. -
style은DEFAULT,ERROR,INFO,SUCCESS,WARNING일 수 있어요. -
body,style,context필드의 사용법에 대해서는,buildkite-agent annotate명령이 이 필드들을 쓰는 방식과 연관된 상세를 Formatting annotations에서 참고하세요.
잡 스코프 annotation 만들기
빌드의 잡 스코프 annotation은 빌드 페이지의 메인 Annotations 탭에서 빌드 annotation 옆에, 그리고 특정 잡의 상세 페이지 Annotations 탭 안에서도 나타나요. 메인 Annotations 탭의 Build와 Job 스코프 필터로 목록을 한 유형으로 좁히세요. 이렇게 하면 annotation을 생성한 특정 잡 옆에서 바로 컨텍스트 정보를 보기가 쉬워져요. 빌드 인터페이스 탐색에 대해서는 build page 문서를 참고하세요.
잡 스코프 annotation이 특히 유용한 사용 사례는 이래요.
- 테스트 매트릭스의 개별 잡에 특정한 테스트 실패
- 잡별 배포 정보나 Terraform plan
- 별도로 봐야 하는 병렬 잡의 결과
- 각 잡이 서로 다른 출력을 만드는 빌드 매트릭스
잡 스코프 annotation은 빌드의 잡 안에서 만들 수 있고, Buildkite의 REST API와 GraphQL API로 외부에서도 만들 수 있어요.
📘 요구사항 잡 스코프 annotation은 Buildkite agent v3.112 이상이 필요하고, 클래식 빌드 페이지 경험에서는 사용할 수 없어요.
빌드의 잡 안에서 만들기
빌드의 잡 안에서 잡 스코프 annotation을 만들려면, 그 잡의 스텝 정의 안에서 --scope job 플래그와 함께 buildkite-agent annotate 명령을 쓰세요.
예컨대 이런 스텝은:
steps:
- label: "\:writing_hand\: Example"
command: |
cat << 'EOF' | buildkite-agent annotate --scope job "Job-specific information" --style "info" --context "agent-cli-example"
### Example job-scoped annotation
This was created from within a build's job.
EOF
기본적으로 annotation은 $BUILDKITE_JOB_ID 환경 변수로 현재 잡에 연관돼요. 다른 잡에 연관시키려면 --job 플래그를 쓰세요.
buildkite-agent annotate --scope "job" --job "job-id" "Annotation for a specific job"
📘
$BUILDKITE_JOB_ID환경 변수 값은 Get a build REST API 쿼리를 실행해, 응답의jobs배열에서 관련 잡의id에서 얻을 수 있어요.
이후 잡에서 이전에 실행된 잡에 annotation을 달려면, buildkite-agent meta-data로 스텝들 사이에 잡 ID를 전달하세요. 예를 들면:
steps:
- label: "First job"
command:
- "buildkite-agent meta-data set 'job_uuid' $$BUILDKITE_JOB_ID"
- "buildkite-agent annotate --scope 'job' 'The first job'"
key: "first_job"
- label: "Second job"
command:
- "JOB_UUID=$$(buildkite-agent meta-data get 'job_uuid');"
- "buildkite-agent annotate --scope 'job' --job $$JOB_UUID --append ' with more content'"
depends_on: ["first_job"]
📘 이 방법은 이미 실행된 스텝에서만 동작해요. 대기 중인 스텝에 annotation을 달려면 REST API나 GraphQL API를 쓰세요.
REST API로 외부에서 만들기
REST API로 잡 스코프 annotation을 만들려면 다음 예시 curl 명령을 실행하세요.
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": "### Job-scoped annotation\n\nThis was created using the REST API.",
"style": "info",
"context": "job-rest-api-example"
}'
각 항목의 의미는 이렇습니다.
-
$TOKEN은 요청이 Buildkite에서 접근해야 하는 관련 Organization과 REST API Scopes로 스코프된 API 액세스 토큰이에요. -
{org.slug}는 이렇게 얻을 수 있어요:-
Buildkite 조직의 전역 내비게이션에서 Pipelines에 접근한 뒤, Buildkite URL 끝부분에서 얻어요.
-
List organizations REST API 쿼리를 실행해 응답의
slug에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations"
-
-
{pipeline.slug}는 이렇게 얻을 수 있어요:-
전역 내비게이션에서 Pipelines > 여러분의 특정 파이프라인에 접근한 뒤, Buildkite URL 끝부분에서 얻어요.
-
List pipelines REST API 쿼리를 실행해 응답의
slug에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines"
-
-
{build.number}는 이렇게 얻을 수 있어요:-
전역 내비게이션에서 Pipelines > 여러분의 특정 파이프라인 > 여러분의 특정 파이프라인 빌드에 접근한 뒤, Buildkite URL에서
builds/뒤의 숫자에서 얻어요. -
List builds for a pipeline REST API 쿼리를 실행해 응답의
number에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds"
-
-
{job.id}는 Get a build REST API 쿼리를 실행해, 응답의jobs배열에서 관련 잡의id에서 얻을 수 있어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds/{build.number}" -
body,style,context필드의 사용법에 대해서는,buildkite-agent annotate명령이 이 필드들을 쓰는 방식과 연관된 상세를 Formatting annotations에서 참고하세요.
GraphQL API로 외부에서 만들기
GraphQL API로 잡 스코프 annotation을 만들려면 다음 예시 mutation을 실행하세요.
mutation {
jobAnnotate(input: {
jobId: "job-id",
body: "### Example job-scoped annotation\n\nThis was created using the GraphQL API.",
style: INFO,
context: "graphql-api-example"
}) {
annotation {
uuid
scope
style
context
body {
html
}
}
job {
id
}
}
}
각 항목의 의미는 이렇습니다.
-
jobId(필수)는 빌드의 잡들을 쿼리해 얻을 수 있어요. 예를 들면:query GetBuildJobs { build(slug: "organization-slug/pipeline-slug/build-number") { jobs(first: 10) { edges { node { ... on JobTypeCommand { id label } } } } } } -
style은DEFAULT,ERROR,INFO,SUCCESS,WARNING일 수 있어요. -
body,style,context필드의 사용법에 대해서는,buildkite-agent annotate명령이 이 필드들을 쓰는 방식과 연관된 상세를 Formatting annotations에서 참고하세요.
annotation 포맷팅하기
빌드 annotation은 여러 가지 스타일, Markdown 문법, CSS 클래스를 지원해요.
빌드 annotation 안에서 아티팩트를 임베드하고 링크할 수도 있어요.
Annotation 스타일
--style 옵션으로 annotation의 시각적 스타일을 바꿀 수 있어요.
서로 다른 annotation 스타일을 보여주는 예시 파이프라인은 이래요.
steps:
- label: "\:console\: Annotation Test"
command: |
buildkite-agent annotate 'Example `default` style' --context 'ctx-default'
buildkite-agent annotate 'Example `info` style' --style 'info' --context 'ctx-info'
buildkite-agent annotate 'Example `warning` style' --style 'warning' --context 'ctx-warn'
buildkite-agent annotate 'Example `error` style' --style 'error' --context 'ctx-error'
buildkite-agent annotate 'Example `success` style' --style 'success' --context 'ctx-success'
지원되는 Markdown 문법
Buildkite Pipelines는 일관되고 모호하지 않은 Markdown 문법을 위해 GitHub Flavored Markdown 확장이 붙은 CommonMark를 써요.
이 Markdown 문법 구현 방법의 상세는 GitHub의 Basic writing and formatting syntax 가이드(우선 참고용)와 GitHub Flavoured Markdown Spec을 참고하세요.
annotation은 GitHub 스타일 문법 하이라이팅, 태스크 목록, 사용자 멘션, 이슈·풀 리퀘스트·커밋 참조의 자동 링크를 지원하지 않아요.
CommonMark는 Markdown 블록 안의 HTML을 지원하지만, 새 줄에서는 Markdown 파싱으로 되돌아가요. HTML이 어떻게 파싱되는지, CommonMark가 어떤 태그를 지원하는지는 CommonMark spec을 참고하세요.
🚧 HTML 제한 annotation은 보안을 위해 정제(sanitize)돼요.
<span>,<div>,<p>,<a>,<img>,<pre>,<code>,<table>,<details>,<summary>,<h1>부터<h6>, 리스트 요소를 포함한 HTML 태그 하위 집합만 허용돼요.<script>,<style>,<iframe>같은 임의 태그는 제거돼요.속성도 제한돼요.
open속성은<details>에서 허용돼요.class속성은 허용되지만 특정 CSS 클래스 이름 allowlist에 한정돼요(아래 지원 CSS 클래스 참고). 링크href값은http,https,mailto,itms-services, 상대 URL 스킴으로 제한돼요.인라인 스타일(예:
style="margin-top: 0;")은 제거돼요. CSS 특이성 때문에 일부 CSS 클래스는 특정 HTML 요소에서 동작하지 않을 수 있어요. 아래에 나열된 지원되는 Basscss 클래스를 대신 쓰세요.
실패 출력 같은 긴 콘텐츠를 접으려고 <details>와 <summary>를 쓰세요. 기본적으로 <details>는 접힌 상태로 시작해요. <details open>은 펼친 상태로 시작해요. <summary>의 내용은 사용자가 섹션을 펼치거나 접을 때 선택하는 라벨이에요. 이 네이티브 동작은 <script> 태그나 Basscss 클래스가 필요 없어요.
예컨대 이 명령은 접힌 실패 출력이 담긴 annotation을 만들어요.
cat <<'EOF' | buildkite-agent annotate --style "error" --context "failure-details"
<details>
<summary>Failure details</summary>
~~~text
... long failure output ...
~~~
</details>
EOF
지원되는 CSS 클래스
annotation은 여러 CSS 클래스를 받아들여요. Basscss에 기반한 레이아웃·포맷팅 통제의 하위 집합과 색상 콘솔 출력을 포함해요.
Basscss
Basscss는 많은 스타일링 작업을 수행하도록 조합할 수 있는 조합 가능한 CSS 클래스 툴킷이에요. Buildkite Pipelines의 annotation은 version 8.0의 다음 Basscss 부분을 받아들여요.
- Align
- Border
- Button
- Background Colors
- Colors
- Flexbox
sm-flex,md-flex,lg-flex를 제외한 전부
- Margin
- Layout
- Float를 제외한 전부(Float 대신 Flexbox를 쓰세요)
- Padding
- Typography
bold,regular,italic,capsleft-align,center,right-align,justifyunderline,truncatelist-reset
- Type Scale
annotation이 지원하는 클래스의 전체 목록은 아래에서 찾을 수 있어요.
bold regular italic caps underline
left-align center right-align justify
align-baseline align-top align-middle align-bottom
list-reset truncate fit
inline block inline-block table table-cell
overflow-hidden overflow-scroll overflow-auto
ml-auto mr-auto mx-auto
flex flex-column flex-wrap flex-auto flex-none
items-start items-end items-center items-baseline items-stretch
self-start self-end self-center self-baseline self-stretch
justify-start justify-end justify-center justify-between justify-around
content-start content-end content-center content-between content-around content-stretch
order-0 order-1 order-2 order-3 order-last
border border-top border-right border-bottom border-left border-none rounded
border-black border-gray border-silver border-white border-aqua border-blue border-navy border-teal
border-green border-olive border-lime border-yellow border-orange border-red border-fuchsia border-purple border-maroon
h1 h2 h3 h4 h5 h6
m0 mt0 mr0 mb0 ml0 mx0 my0 m1
mt1 mr1 mb1 ml1 mx1 my1
m2 mt2 mr2 mb2 ml2 mx2 my2
m3 mt3 mr3 mb3 ml3 mx3 my3
m4 mt4 mr4 mb4 ml4 mx4 my4
mxn1 mxn2 mxn3 mxn4
p0 pt0 pr0 pb0 pl0 px0 py0
p1 pt1 pr1 pb1 pl1 py1 px1
p2 pt2 pr2 pb2 pl2 py2 px2
p3 pt3 pr3 pb3 pl3 py3 px3
p4 pt4 pr4 pb4 pl4 py4 px4
col-1 col-2 col-3 col-4 col-5 col-6
col-7 col-8 col-9 col-10 col-11 col-12
sm-col-1 sm-col-2 sm-col-3 sm-col-4 sm-col-5 sm-col-6
sm-col-7 sm-col-8 sm-col-9 sm-col-10 sm-col-11 sm-col-12
md-col-1 md-col-2 md-col-3 md-col-4 md-col-5 md-col-6
md-col-7 md-col-8 md-col-9 md-col-10 md-col-11 md-col-12
lg-col-1 lg-col-2 lg-col-3 lg-col-4 lg-col-5 lg-col-6
lg-col-7 lg-col-8 lg-col-9 lg-col-10 lg-col-11 lg-col-12
black gray silver white aqua blue navy teal green olive lime
yellow orange red fuchsia purple maroon muted
btn btn-sm btn-lg btn-primary
bg-black bg-gray bg-silver bg-white bg-aqua bg-blue
bg-navy bg-teal bg-green bg-olive bg-lime bg-yellow
bg-orange bg-red bg-fuchsia bg-purple bg-maroon bg-muted
색상 콘솔 출력
annotation의 콘솔 출력은 term이나 terminal 문법으로 표시된 Markdown 블록으로 감싸면 ANSI 색상으로 표시될 수 있어요. annotation당 10개 블록의 제한이 있어요.
```term
\x1b[31mFailure/Error:\x1b[0m \x1b[32mexpect\x1b[0m(new_item.created_at).to eql(now)
\x1b[31m expected: 2018-06-20 19:42:26.290538462 +0000\x1b[0m
\x1b[31m got: 2018-06-20 19:42:26.290538000 +0000\x1b[0m
\x1b[31m (compared using eql?)\x1b[0m
```
📘 터미널로 echo할 때는 코드 블록을 구분하는 백틱(
`)을 이스케이프하세요. 셸이 해석하는 명령으로 오인하지 않게 하는 거예요.
다음 파이프라인은 이스케이프된 Markdown 블록을 출력하고, \n으로 줄바꿈을 더하고, 빨간 ANSI 코드 \033[0;31m으로 test를 포맷한 뒤 나머지 출력을 \033[0m으로 리셋해요. echo 명령에 -e를 넘기면 백슬래시 이스케이프 코드가 해석돼요(기본은 해석하지 않는 거예요).
steps:
- label: "Annotation Test"
command:
- echo -e "\`\`\`term\nThis is a \033[0;31mtest\033[0m\n\`\`\`" | buildkite-agent annotate
{: codeblock-file="pipeline.yml"}
결과는 buildkite-agent annotate 명령으로 파이프돼요.
더 복잡한 annotation을 위해서는 파일 전체를 buildkite-agent annotate 명령으로 파이프하세요.
printf '%b\n' "$(cat markdown-for-annotation.md)" | buildkite-agent annotate
우리의 terminal to HTML 도구를 쓴다면, 출력을 <pre class="term"><code></code></pre> 태그로 감싸세요. 터미널 색상 스타일을 표시하면서 다시 처리하지는 않아요.
<pre class="term">
<code>
terminal-to-html output
</code>
</pre>
annotation에 아티팩트 임베드·링크하기
업로드된 아티팩트는 이미지 소스에 artifact:// 접두사로 참조해 annotation에 임베드할 수 있어요.
steps:
- label: "\:console\: Annotation Test"
command: |
buildkite-agent artifact upload "indy.png"
cat << EOF | buildkite-agent annotate --style "info"
<img src="artifact://indy.png" alt="Belongs in a museum" height=250 >
EOF
{: codeblock-file="pipeline.yml"}
업로드된 아티팩트로 중요한 파일의 바로가기를 링크할 수도 있어요.
steps:
- label: "Upload Coverage Report"
command: |
buildkite-agent artifact upload "coverage/*"
cat << EOF | buildkite-agent annotate --style "info"
Read the <a href="artifact://coverage/index.html">uploaded coverage report</a>
EOF
{: codeblock-file="pipeline.yml"}
빌드의 annotation 목록 조회하기
빌드의 모든 빌드·잡 스코프 annotation은 REST API나 GraphQL API로 회수할 수 있어요.
REST API 사용하기
Buildkite REST API로 빌드의 빌드·잡 스코프 annotation 목록을 조회하세요.
curl -H "Authorization: Bearer ***" \
-X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds/{build.number}/annotations"
각 항목의 의미는 이렇습니다.
-
$TOKEN은 요청이 Buildkite에서 접근해야 하는 관련 Organization과 REST API Scopes로 스코프된 API 액세스 토큰이에요. -
{org.slug}는 이렇게 얻을 수 있어요:-
Buildkite 조직의 전역 내비게이션에서 Pipelines에 접근한 뒤, Buildkite URL 끝부분에서 얻어요.
-
List organizations REST API 쿼리를 실행해 응답의
slug에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations"
-
-
{pipeline.slug}는 이렇게 얻을 수 있어요:-
전역 내비게이션에서 Pipelines > 여러분의 특정 파이프라인에 접근한 뒤, Buildkite URL 끝부분에서 얻어요.
-
List pipelines REST API 쿼리를 실행해 응답의
slug에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines"
-
-
{build.number}는 이렇게 얻을 수 있어요:-
전역 내비게이션에서 Pipelines > 여러분의 특정 파이프라인 > 여러분의 특정 파이프라인 빌드에 접근한 뒤, Buildkite URL에서
builds/뒤의 숫자에서 얻어요. -
List builds for a pipeline REST API 쿼리를 실행해 응답의
number에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds"
-
GraphQL API 사용하기
GraphQL API로 빌드의 빌드·잡 스코프 annotation 목록을 조회하려면 다음 예시 쿼리를 실행하세요.
query GetBuildAnnotations {
build(uuid: "build-uuid") {
number
annotations(first: 10) {
edges {
node {
uuid
context
style
body {
text
html
}
createdAt
}
}
}
}
}
build-uuid(필수)는 Get builds GraphQL API 쿼리를 실행해, 응답의 빌드 번호(number 값으로 지정돼요)와 연관된 uuid에서 얻을 수 있어요. 예를 들면:
query GetBuilds {
pipeline(slug: "organization-slug/pipeline-slug") {
builds(first: 10) {
edges {
node {
uuid
number
}
}
}
}
}
잡의 annotation 목록 조회하기
특정 잡의 잡 스코프 annotation은 REST API나 GraphQL API로 회수할 수 있어요.
REST API 사용하기
REST API로 특정 잡의 잡 스코프 annotation 목록을 조회하려면 다음 예시 curl 명령을 실행하세요.
curl -H "Authorization: Bearer ***" \
-X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds/{build.number}/jobs/{job.id}/annotations"
각 항목의 의미는 이렇습니다.
-
$TOKEN은 요청이 Buildkite에서 접근해야 하는 관련 Organization과 REST API Scopes로 스코프된 API 액세스 토큰이에요. -
{org.slug}는 이렇게 얻을 수 있어요:-
Buildkite 조직의 전역 내비게이션에서 Pipelines에 접근한 뒤, Buildkite URL 끝부분에서 얻어요.
-
List organizations REST API 쿼리를 실행해 응답의
slug에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations"
-
-
{pipeline.slug}는 이렇게 얻을 수 있어요:-
전역 내비게이션에서 Pipelines > 여러분의 특정 파이프라인에 접근한 뒤, Buildkite URL 끝부분에서 얻어요.
-
List pipelines REST API 쿼리를 실행해 응답의
slug에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines"
-
-
{build.number}는 이렇게 얻을 수 있어요:-
전역 내비게이션에서 Pipelines > 여러분의 특정 파이프라인 > 여러분의 특정 파이프라인 빌드에 접근한 뒤, Buildkite URL에서
builds/뒤의 숫자에서 얻어요. -
List builds for a pipeline REST API 쿼리를 실행해 응답의
number에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds"
-
-
{job.id}는 Get a build REST API 쿼리를 실행해, 응답의jobs배열에서 관련 잡의id에서 얻을 수 있어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds/{build.number}"
GraphQL API 사용하기
GraphQL API로 특정 잡의 잡 스코프 annotation 목록을 조회하려면 다음 예시 쿼리를 실행하세요.
query GetJobAnnotations {
job(uuid: "job-uuid") {
... on JobTypeCommand {
annotations(first: 10) {
edges {
node {
uuid
scope
context
style
body {
text
html
}
}
}
}
}
}
}
job-uuid는 잡의 UUID이고, 빌드의 잡들을 쿼리해 얻을 수 있어요. 예를 들면:
query GetBuildJobs {
build(slug: "organization-slug/pipeline-slug/build-number") {
jobs(first: 10) {
edges {
node {
... on JobTypeCommand {
uuid
label
}
}
}
}
}
}
annotation 제거하기
빌드·잡 스코프 annotation은 빌드의 잡 안에서 제거할 수 있고, REST API로 외부에서도 제거할 수 있어요. GraphQL API로 annotation을 제거하는 건 지원되지 않아요.
빌드의 잡 안에서 제거하기
빌드의 잡 안에서 빌드·잡 스코프 annotation을 제거하려면, 그 잡의 스텝 정의 안에서 buildkite-agent annotation remove 명령을 쓰세요.
예를 들면:
steps:
- label: "\:exploding-death-star\: Remove annotation"
command: buildkite-agent annotation remove --context "agent-cli-example"
이런 식으로 annotation을 제거하는 게 가장 흔한 접근이에요. 이 스텝들은 여러분의 파이프라인 빌드의 일부로 실행되거든요.
REST API로 외부에서 제거하기
REST API로 빌드·잡 스코프 annotation을 제거하려면 다음 예시 curl 명령을 실행하세요.
curl -H "Authorization: Bearer ***" \
-X DELETE "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds/{build.number}/annotations/{annotation.uuid}"
각 항목의 의미는 이렇습니다.
-
$TOKEN은 요청이 Buildkite에서 접근해야 하는 관련 Organization과 REST API Scopes로 스코프된 API 액세스 토큰이에요. -
{org.slug}는 이렇게 얻을 수 있어요:-
Buildkite 조직의 전역 내비게이션에서 Pipelines에 접근한 뒤, Buildkite URL 끝부분에서 얻어요.
-
List organizations REST API 쿼리를 실행해 응답의
slug에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations"
-
-
{pipeline.slug}는 이렇게 얻을 수 있어요:-
전역 내비게이션에서 Pipelines > 여러분의 특정 파이프라인에 접근한 뒤, Buildkite URL 끝부분에서 얻어요.
-
List pipelines REST API 쿼리를 실행해 응답의
slug에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines"
-
-
{build.number}는 이렇게 얻을 수 있어요:-
전역 내비게이션에서 Pipelines > 여러분의 특정 파이프라인 > 여러분의 특정 파이프라인 빌드에 접근한 뒤, Buildkite URL에서
builds/뒤의 숫자에서 얻어요. -
List builds for a pipeline REST API 쿼리를 실행해 응답의
number에서 이 값을 얻어요. 예를 들면:curl -H "Authorization: Bearer ***" \ -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/pipelines/{pipeline.slug}/builds"
-
-
{annotation.uuid}는 빌드의 annotation 목록을 조회해 응답에서id값을 추출해 얻을 수 있어요. 이 값은 Buildkite 인터페이스에서는 얻을 수 없어요.
annotation으로 테스트 결과 보고하기
annotation은 파이프라인의 서로 다른 스텝에서 발생하는 테스트 실패를 렌더링하는 훌륭한 방법이에요.
junit-annotate plugin은 빌드의 모든 junit.xml 아티팩트를 단일 annotation으로 변환해요.
steps:
- command: test.sh
parallelism: 50
artifact_paths: tmp/junit-*.xml
- wait: ~
continue_on_failure: true
- plugins:
- junit-annotate#v2.7.0:
artifacts: tmp/junit-*.xml
{: codeblock-file="pipeline.yml"}
빌드 도구로 Bazel을 쓴다면, Bazel 빌드 이벤트에서 annotation을 생성하는 튜토리얼을 Creating dynamic pipelines and build annotations using Bazel에서 참고하세요.