Build run times

Hey BuildKite team, can you tell me if the build runtime value includes the wait time of a job to get picked up? Or is it only how long the build has been running for (not including wait time).

Hey @jonathanyeong,

Welcome to the Buildkite community forum.

Total Job Run Time in Buildkite only includes the time jobs spent running on agent. It does not include the waiting time for jobs to be picked up by agent.

If you want to check the waiting time for the agent, you can:

  1. Check the right side of each step in the Buildkite UI: Buildkite displays the waiting time alongside the execution time for each step in the UI. This will give you a quick view of how long the step waited for an agent.

  2. Go to the Timeline under the step: Navigate to the step’s Timeline section in the Buildkite UI. The Timeline provides detailed information about the lifecycle of the step, including when it was queued and when it started running.

Thanks,

Thank you Ivana. So the “Passed in 14m 36s” is only the job runtime.

Does buildkite track total wait time on a job? Or would i have to calculate it manually / through API. For context, our company is using agent-stack-k8s.

Yes, you can calculate the diff between these two timestamps to get the total wait time.

{
  build(slug: "organization-slug/build-slug") {
    jobs {
      edges {
        node {
          id
          state
          createdAt
          startedAt
        }
      }
    }
  }
}

Other option would be to use the custom script to get wait time.

This script uses our builds API and does some filtering using jq :
# Using the below Curl to fetch the build information:
build_api_response=$(curl -s -H "Authorization: Bearer ${API_TOKEN}" 
  "<https://api.buildkite.com/v2/organizations/${ORG_SLUG}/pipelines/${PIPELINE_SLUG}/builds/${BUILD_NUMBER}>")


# Print the raw JSON response for debugging if needed 
# echo "Raw JSON response:"
# echo "$response" | jq .

# Using the below script to calculate the job wait time. The idea is that wait time is the difference between created time and start time 
echo "$build_api_response" | jq -r '
  def removing_fractional_seconds:
    sub("\\.[0-9]+Z"; "Z");

  if .jobs then
    .jobs[] |
    select(.started_at != null) |
    {
      job_name: .name,
      waiting_time: ( ( ( .started_at | removing_fractional_seconds | fromdateiso8601 ) - ( .created_at | removing_fractional_seconds | fromdateiso8601 ) ) | . as $time | "\($time / 3600 | floor) hours, \($time % 3600 / 60 | floor) minutes, \($time % 60) seconds" )
    } |
    "Job \(.job_name) waited \(.waiting_time) to get an agent."
  else
    "No build information was found : Please check if all variables are declared accurately and build exists. Uncomment Print the raw JSON response for debugging if needed."
  end
'

Thanks,