For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/ko/api/latest/code-coverage/get-per-file-code-coverage-data.md. A documentation index is available at /llms.txt.
Language
Datadog site

Get per-file code coverage data

POSThttps://api.datadoghq.com/api/v2/code-coverage/fileshttps://api.us3.datadoghq.com/api/v2/code-coverage/fileshttps://api.us5.datadoghq.com/api/v2/code-coverage/fileshttps://api.datadoghq.eu/api/v2/code-coverage/fileshttps://api.ap1.datadoghq.com/api/v2/code-coverage/fileshttps://api.ap2.datadoghq.com/api/v2/code-coverage/fileshttps://api.uk1.datadoghq.com/api/v2/code-coverage/fileshttps://api.ddog-gov.com/api/v2/code-coverage/fileshttps://api.us2.ddog-gov.com/api/v2/code-coverage/files

개요

Retrieve per-file code coverage data for a specific commit, branch, or pull request. Exactly one of commit_sha, branch, or pr_number must be provided. Optionally filter by service, codeowner, or flag (at most one).

This endpoint requires the code_coverage_read permission.

OAuth apps require the code_coverage_read authorization scope to access this endpoint.

요청

Body Data (required)

항목
유형
설명
data [required]
object

Data object for files coverage request.

응답

OK

Response object containing per-file code coverage data.

항목
유형
설명
data
object

Data object for files coverage response.

코드 예시

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/code-coverage/files" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "changed_only": true,
      "commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588",
      "repository_url": "https://github.com/datadog/test-service"
    },
    "type": "ci_app_coverage_files_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/code-coverage/files" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "changed_only": true,
      "commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588",
      "repository_url": "https://github.com/datadog/test-service"
    },
    "type": "ci_app_coverage_files_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/code-coverage/files" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "changed_only": true,
      "commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588",
      "repository_url": "https://github.com/datadog/test-service"
    },
    "type": "ci_app_coverage_files_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/code-coverage/files" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "changed_only": true,
      "commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588",
      "repository_url": "https://github.com/datadog/test-service"
    },
    "type": "ci_app_coverage_files_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/code-coverage/files" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "changed_only": true,
      "commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588",
      "repository_url": "https://github.com/datadog/test-service"
    },
    "type": "ci_app_coverage_files_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/code-coverage/files" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "changed_only": true,
      "commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588",
      "repository_url": "https://github.com/datadog/test-service"
    },
    "type": "ci_app_coverage_files_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/code-coverage/files" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "changed_only": true,
      "commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588",
      "repository_url": "https://github.com/datadog/test-service"
    },
    "type": "ci_app_coverage_files_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/code-coverage/files" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "changed_only": true,
      "commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588",
      "repository_url": "https://github.com/datadog/test-service"
    },
    "type": "ci_app_coverage_files_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/code-coverage/files" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "changed_only": true,
      "commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588",
      "repository_url": "https://github.com/datadog/test-service"
    },
    "type": "ci_app_coverage_files_request"
  }
}
EOF