Pjotr Prins <pjotr.publi...@thebird.nl> skribis:

> I asked this before. Would it be possible that hydra exports JSON (or
> something) so we can get the package status without having to parse
> HTML? So the output of 
>
>   http://hydra.gnu.org/job/gnu/master/ruby-2.2.3.x86_64-linux
>
> would be JSON with
>
>   http://hydra.gnu.org/job/gnu/master/ruby-2.2.3.x86_64-linux.json

Everything is possible.  :-)

It turns out that Hydra has a bunch of things under
lib/Hydra/Controller/API.pm¹.  For example:

  http://hydra.gnu.org/api/nrqueue
  http://hydra.gnu.org/api/latestbuilds?nr=10
  http://hydra.gnu.org/api/jobsets?project=gnu
  
http://hydra.gnu.org/api/nrbuilds?nr=2&period=day&project=gnu&jobset=core-updates

(Damn, we could even have an Emacs mode to display all this!)

The /latestbuilds URL provides a “buildstatus” key, like this:

  { "project":"gnu",
    "timestamp":1442315120,
    "nixname":"gcr-3.16.0",
    "job":"gcr-3.16.0.mips64el-linux",
    "system":"mips64el-linux",
    "finished":1,
    "buildstatus":2,
    "jobset":"core-updates",
    "id":683368 }

The meaning of the “buildstatus” value is given in hydra-postgresql.sql:

    -- Status codes:
    --   0 = succeeded
    --   1 = build of this derivation failed
    --   2 = build of some dependency failed
    --   3 = other failure (see errorMsg)
    --   4 = build cancelled (removed from queue; never built)
    --   5 = build not done because a dependency failed previously (obsolete)
    buildStatus   integer,

So it’s possible to query the build status of some of the latest builds.

However, we’d need a different URL to get what you want.  That seems to
be quite simple to do.  Would you or someone else be willing to hack on
this?

Another useful hack: in gnu.org/s/guix/packages, add a JS snippet that
queries http://hydra.gnu.org/api/jobsets?project=gnu and displays some
of the info.

Thanks,
Ludo’.

¹ https://github.com/NixOS/hydra/blob/master/src/lib/Hydra/Controller/API.pm

Reply via email to