본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

에이전트 API

원문 보기 위키 갱신

Buildkite 에이전트는 작고 안정적인 크로스 플랫폼 빌드 실행기예요. 주요 책임은 buildkite.com에서 작업을 폴링하고, 빌드 작업을 실행하며, 작업의 상태 코드와 출력 로그를 보고하고, 작업의 아티팩트를 업로드하는 것이에요.

출처: 문서

본문

에이전트 데이터 모델

id 에이전트의 UUID
graphql_id 에이전트의 GraphQL ID
url 에이전트의 정식 API URL
web_url Buildkite의 에이전트 URL
name 에이전트의 이름
connection_state 연결 상태: never_connected, connected, disconnected, stopping, stopped 또는 lost
hostname 에이전트를 실행 중인 머신의 호스트 이름
ip_address 에이전트의 IP 주소
user_agent 에이전트 버전과 플랫폼을 식별하는 사용자 에이전트 문자열
version Buildkite 에이전트의 버전
os_id 러너의 운영 체제 식별자(예: linux, darwin)
arch 러너의 CPU 아키텍처(예: amd64, arm64)
queue 에이전트가 등록된 큐
creator 에이전트를 등록한 사용자 또는 토큰
created_at 에이전트가 등록된 시점
connected_at 에이전트가 연결된 시점
disconnected_at 에이전트가 정상적으로 연결 해제된 시점(아직 연결되어 있거나 손실된 경우 null)
lost_at 예상치 못한 연결 해제로 에이전트가 손실로 표시된 시점(손실되지 않은 경우 null)
stopped_at 에이전트가 정지된 시점(정지되지 않은 경우 null)
job 에이전트가 현재 실행 중인 작업(있는 경우)
last_job_finished_at 에이전트가 마지막으로 작업을 완료한 시점
priority 작업 배정을 위한 우선순위 값
meta_data key=value 형식의 에이전트 태그 배열

에이전트 목록 조회

조직의 연결된 에이전트와 정지 중인 에이전트의 페이지네이션된 목록을 반환해요. 다른 연결 상태의 에이전트는 반환되지 않아요. 어떤 연결 상태든 알려진 에이전트를 검색하려면 get an agent를 사용해요.

curl -H "Authorization: Bearer ***" \
  -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/agents"
[
  {
    "id": "0b461f65-e7be-4c80-888a-ef11d81fd971",
    "graphql_id": "QWdlbnQtLS1mOTBhNzliNC01YjJlLTQzNzEtYjYxZS03OTA4ZDAyNmUyN2E=",
    "url": "https://api.buildkite.com/v2/organizations/my-great-org/agents/my-agent",
    "web_url": "https://buildkite.com/organizations/my-great-org/clusters/78088c9a-6e72-4896-848d-e6f479f50c24/queues/c109939f-3b71-4cd3-b175-8eb79d2eb38e/agents/0b461f65-e7be-4c80-888a-ef11d81fd971",
    "name": "my-agent",
    "connection_state": "connected",
    "hostname": "some.server",
    "ip_address": "144.132.19.12",
    "user_agent": "buildkite-agent/2.1.0 (linux; amd64)",
    "version": "2.1.0",
    "os_id": "linux",
    "arch": "amd64",
    "queue": "default",
    "creator": {
      "id": "2eba97bc-7cc7-427f-8feb-1008c72aa1d8",
      "name": "Keith Pitt",
      "email": "me@keithpitt.com",
      "avatar_url": "https://www.gravatar.com/avatar/e14f55d3f939977cecbf51b64ff6f861",
      "created_at": "2015-05-09T21:05:59.874Z"
    },
    "created_at": "2014-02-24T22:33:45.263Z",
    "connected_at": "2014-02-24T22:33:45.263Z",
    "disconnected_at": null,
    "lost_at": null,
    "stopped_at": null,
    "job": {
      "id": "cd164055-9649-452b-8d8e-28fe67370a1e",
      "graphql_id": "Sm9iLS0tMTQ4YWQ0MzgtM2E2My00YWIxLWIzMjItNzIxM2Y3YzJhMWFi",
      "type": "script",
      "name": "rspec",
      "agent_query_rules": ["*"],
      "state": "passed",
      "build_url": "https://api.buildkite.com/v2/organizations/my-great-org/pipelines/sleeper/builds/50",
      "web_url": "https://buildkite.com/my-great-org/sleeper/builds/50#cd164055-9649-452b-8d8e-28fe67370a1e",
      "log_url": "https://api.buildkite.com/v2/organizations/my-great-org/pipelines/sleeper/builds/50/jobs/cd164055-9649-452b-8d8e-28fe67370a1e/log",
      "raw_log_url": "https://api.buildkite.com/v2/organizations/my-great-org/pipelines/sleeper/builds/50/jobs/cd164055-9649-452b-8d8e-28fe67370a1e/log.txt",
      "artifacts_url": "https://api.buildkite.com/v2/organizations/my-great-org/pipelines/sleeper/builds/50/jobs/cd164055-9649-452b-8d8e-28fe67370a1e/artifacts",
      "script_path": "sleep 1",
      "command": "sleep 1",
      "soft_failed": false,
      "exit_status": 0,
      "artifact_paths": "*",
      "agent": null,
      "created_at": "2015-07-30T12:58:22.942Z",
      "scheduled_at": "2015-07-30T12:58:22.935Z",
      "started_at": "2015-07-30T12:58:34.000Z",
      "finished_at": "2015-07-30T12:58:37.000Z"
    },
    "last_job_finished_at": null,
    "priority": null,
    "meta_data": ["key1=val1","key2=val2"]
  }
]

선택적 쿼리 문자열 매개변수:

name 주어진 에이전트 이름으로 결과를 필터링 예: ?name=ci-agent-1
hostname 주어진 호스트 이름으로 결과를 필터링 예: ?hostname=ci-box-1
version 주어진 정확한 버전 번호로 결과를 필터링 예: ?version=2.1.0
cluster_queue_id 주어진 큐 UUID에 등록된 에이전트로만 결과를 필터링 예: ?cluster_queue_id=c109939f-3b71-4cd3-b175-8eb79d2eb38e

필수 범위: read_agents

성공 응답: 200 OK

에이전트 조회

고유 ID로 조회한 단일 에이전트에 대한 세부 정보를 반환해요. 실행 중이거나 연결 해제된 에이전트를 포함한 모든 유효한 에이전트가 반환될 수 있어요.

curl -H "Authorization: Bearer ***" \
  -X GET "https://api.buildkite.com/v2/organizations/{org.slug}/agents/{id}"
{
  "id": "0b461f65-e7be-4c80-888a-ef11d81fd971",
  "graphql_id": "QWdlbnQtLS1mOTBhNzliNC01YjJlLTQzNzEtYjYxZS03OTA4ZDAyNmUyN2E=",
  "url": "https://api.buildkite.com/v2/organizations/my-great-org/agents/my-agent",
  "web_url": "https://buildkite.com/organizations/my-great-org/clusters/78088c9a-6e72-4896-848d-e6f479f50c24/queues/c109939f-3b71-4cd3-b175-8eb79d2eb38e/agents/0b461f65-e7be-4c80-888a-ef11d81fd971",
  "name": "my-agent",
  "connection_state": "connected",
  "hostname": "some.server",
  "ip_address": "144.132.19.12",
  "user_agent": "buildkite-agent/2.1.0 (linux; amd64)",
  "version": "2.1.0",
  "os_id": "linux",
  "arch": "amd64",
  "queue": "default",
  "creator": {
    "id": "2eba97bc-7cc7-427f-8feb-1008c72aa1d8",
    "graphql_id": "VXNlci0tLThmNzFlOWI1LTczMDEtNDI4ZS1hMjQ1LWUwOWI0YzI0OWRiZg==",
    "name": "Keith Pitt",
    "email": "me@keithpitt.com",
    "avatar_url": "https://www.gravatar.com/avatar/e14f55d3f939977cecbf51b64ff6f861",
    "created_at": "2015-05-09T21:05:59.874Z"
  },
  "created_at": "2015-05-09T21:05:59.874Z",
  "connected_at": "2015-05-09T21:05:59.874Z",
  "disconnected_at": null,
  "lost_at": null,
  "stopped_at": null,
  "job": {
    "id": "cd164055-9649-452b-8d8e-28fe67370a1e",
    "graphql_id": "Sm9iLS0tZGM5YTg5MmQtM2I5Ny00MzgyLWEzYzItNWJhZmU5M2RlZWI1",
    "type": "script",
    "name": "rspec",
    "agent_query_rules": ["*"],
    "state": "passed",
    "build_url": "https://api.buildkite.com/v2/organizations/my-great-org/pipelines/sleeper/builds/50",
    "web_url": "https://buildkite.com/my-great-org/sleeper/builds/50#cd164055-9649-452b-8d8e-28fe67370a1e",
    "log_url": "https://api.buildkite.com/v2/organizations/my-great-org/pipelines/sleeper/builds/50/jobs/cd164055-9649-452b-8d8e-28fe67370a1e/log",
    "raw_log_url": "https://api.buildkite.com/v2/organizations/my-great-org/pipelines/sleeper/builds/50/jobs/cd164055-9649-452b-8d8e-28fe67370a1e/log.txt",
    "artifacts_url": "https://api.buildkite.com/v2/organizations/my-great-org/pipelines/sleeper/builds/50/jobs/cd164055-9649-452b-8d8e-28fe67370a1e/artifacts",
    "script_path": "sleep 1",
    "command": "sleep 1",
    "soft_failed": false,
    "exit_status": 0,
    "artifact_paths": "*",
    "agent": null,
    "created_at": "2015-07-30T12:58:22.942Z",
    "scheduled_at": "2015-07-30T12:58:22.935Z",
    "started_at": "2015-07-30T12:58:34.000Z",
    "finished_at": "2015-07-30T12:58:37.000Z"
  },
  "last_job_finished_at": null,
  "priority": null,
  "meta_data": ["key1=val1","key2=val2"]
}

필수 범위: read_agents

성공 응답: 200 OK

에이전트 정지

📘 필요한 권한 에이전트를 정지하려면 다음 중 하나가 필요해요.

  • write_agents 범위를 가진 관리자 사용자 API 토큰.
  • 또는 Buildkite 조직의 파이프라인 보안 기능을 사용한다면, Stop Agents 권한이 있는 사용자 토큰.

에이전트에게 새 빌드 작업을 받는 것을 중단하고 스스로 종료하라고 지시해요.

curl -H "Authorization: Bearer ***" \
  -X PUT "https://api.buildkite.com/v2/organizations/{org.slug}/agents/{id}/stop" \
  -H "Content-Type: application/json" \
  -d '{
    "force": true
  }'

선택적 요청 본문 속성:

force 에이전트가 현재 작업을 처리 중이라면, 그 작업과 빌드가 취소돼요. 기본값: true

필수 범위: write_agents

성공 응답: 204 No Content

오류 응답:

400 Bad Request { "message": "Can only stop connected agents" }

에이전트 일시 중지

📘 필요한 권한 에이전트를 일시 중지하려면 다음 중 하나가 필요해요.

  • write_agents 범위를 가진 관리자 사용자 API 토큰.
  • 또는 Buildkite 조직의 파이프라인 보안 기능을 사용한다면, Stop Agents 권한이 있는 사용자 토큰.

에이전트에 작업 디스패치를 막고, (그 외에는 작업이 완료되거나 시간 초과될 때 종료되는) 에이전트가 현재 작업을 마친 후에도 계속 실행되도록 지시해요.

curl -H "Authorization: Bearer ***" \
  -X PUT "https://api.buildkite.com/v2/organizations/{org.slug}/agents/{id}/pause" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "A short note explaining why this agent is being paused",
    "timeout_in_minutes": 60
  }'

선택적 요청 본문 속성:

note 에이전트가 일시 중지되는 이유를 설명하는 짧은 메모
timeout_in_minutes 에이전트가 자동으로 재개되는 시간(분) 생략 시: 에이전트의 기존 시간 초과 값(처음엔 5)을 사용해요. 최대값: 10080(7일).

필수 범위: write_agents

성공 응답: 204 No Content

오류 응답:

404 Not Found { "message": "No agent found" }
422 Unprocessable Entity { "message": "Agent is already paused" }
422 Unprocessable Entity { "message": "Only connected agents may be paused" }

에이전트 재개

📘 필요한 권한 일시 중지된 에이전트를 재개하려면 다음 중 하나가 필요해요.

  • write_agents 범위를 가진 관리자 사용자 API 토큰.
  • 또는 Buildkite 조직의 파이프라인 보안 기능을 사용한다면, Stop Agents 권한이 있는 사용자 토큰.

에이전트에 작업 디스패치를 재개하고, 에이전트에게 정상 운영을 재개하라고 지시해요.

curl -H "Authorization: Bearer ***" \
  -X PUT "https://api.buildkite.com/v2/organizations/{org.slug}/agents/{id}/resume" \
  -H "Content-Type: application/json" \
  -d '{}'

필수 범위: write_agents

성공 응답: 204 No Content

오류 응답:

404 Not Found { "message": "No agent found" }
422 Unprocessable Entity { "message": "Agent is not paused" }

에이전트 토큰

에이전트 토큰은 클러스터 REST API 엔드포인트를 통해 생성돼요.

더 알아보기 (Learn more)

에이전트 API는 조직의 빌드 러너를 프로그래매틱하게 관리하게 해줘요. GET으로 에이전트의 목록·세부 정보를, PUT /stop, PUT /pause, PUT /resume으로 에이전트를 정지·일시 중지·재개할 수 있어요. 필수 범위는 read_agents(조회)와 write_agents(정지·일시 중지·재개)이며, 정지·일시 중지·재개는 추가로 적절한 조직 권한도 요구해요. 에이전트 토큰 자체는 클러스터 API에서 관리하니 이 페이지의 표와 응답 구조를 참고해 원하는 필드를 활용해 보세요.