buildkite / feedback

Got feedback? Please let us know!
https://buildkite.com
25 stars 24 forks source link

Getting duration values via the GraphQL endpoint #465

Open gerrywastaken opened 5 years ago

gerrywastaken commented 5 years ago

Is there any way to get the duration for a build from the GraphQL API?

This number (or something close to it):

screen shot 2018-10-07 at 8 06 47 pm

I can see createdAt, scheduledAt, finishedAt, canceledAt, but but nothing for duration. Trying to calculate this using the above values also doesn't work as it doesn't take into account pauses during block steps, like the "Passed in" calculation does.

toolmantim commented 5 years ago

Hey Gerry! startedAt should be the property you need.

So the calc would be finishedAt - startedAt for build duration. If you want build wait time (how long spent waiting for an agent) that'd be startedAt - runnableAt.

Let me know if that works for you! If it doesn't, you can re-open this or shoot an email to support ☺️

gerrywastaken commented 5 years ago

@toolmantim I think startedAt and runnableAt are only available on the Job Type, but I'm needing the values for the build (I believe):

query:

query {
  build(uuid: "b87f86b4-5de8-4d5d-a073-4b3184c0b969") {
    createdAt
    scheduledAt
    finishedAt,
    canceledAt
  }
}

result:

{
  "data": {
    "build": {
      "createdAt": "2018-10-08T01:58:55Z",
      "scheduledAt": "2018-10-08T01:58:55Z",
      "finishedAt": "2018-10-08T02:40:32Z",
      "canceledAt": null
    }
  }
}
screen shot 2018-10-08 at 2 51 51 pm
ActionController::Base.helpers.distance_of_time_in_words(
   DateTime.parse('2018-10-08T02:40:32Z'),
   DateTime.parse('2018-10-08T01:58:55Z')
)

=> "42 minutes"

If it doesn't, you can re-open this [...]

Unfortunately, Github doesn't allow me to do that if a ticket is closed by somebody else.