buildkite / feedback

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

Ability to see all builds an agent has run #286

Closed seanabraham closed 6 years ago

seanabraham commented 6 years ago

When diagnosing a problem, it's usually helpful to see when it started occurring on a given agent. Right now, going to an agent's page only show the last 10 builds. In certain cases it may have happened more than 10 builds ago and then it becomes really hard to find information about what may have caused a breakage. As such, it would be really helpful if there was some sort of list which listed all prior builds on a given agent, it could be paginated just like the list of builds for a given branch.

ticky commented 6 years ago

Hi Sean, whilst we don’t yet show it in the UI, the full list of builds is definitely available via our GraphQL API. Hopefully we can add pagination to that page soon :)

seanabraham commented 6 years ago

Hi @ticky! Yeah I remember talking with @keithpitt about this a while ago and he suggested using the GraphQL API as a workaround in the meantime too. I tried a bit yesterday and struggled to put the right query together.

I was using the Graphiql instance running at https://graphql.buildkite.com/explorer and had a query like:

query {
  agent(slug:"org/long-slug-hash-thing-here") {
    id
    jobs {
      edges {
        node
      }
    }
  }
}

But any time I tried to add a property under node (sorry I don't really know the GraphQL semantics), the explorer returned something like: Selections can't be made directly on unions (see selections on Job)

If I was trying to view a list all the build jobs (with names and statuses) that a given agent has run, how would I go about doing that via a GraphQL query?

Thanks!

ticky commented 6 years ago

Ah, that’s because the Job type is a union type! This means you have to specify a “fragment” for each of the types it can be.

Given agents only run JobTypeCommand jobs, we only need to specify a fragment for that type. To query their details, you can do this:

query {
  agent(slug:"org/long-slug-hash-thing-here") {
    jobs {
      edges {
        node {
          ...on JobTypeCommand {
            state
            build {
              pipeline {
                name
              }
              number
              message
            }
            uuid
          }
        }
      }
    }
  }
}

This’ll give you the pipeline name, build number, and job state and UUID!

seanabraham commented 6 years ago

Fantastic, this is really helpful! Thanks @ticky!