ReleaseEngineering/Applications/BuildAPI

From MozillaWiki
Jump to navigation Jump to search

includes self-serve, wait time reports, pending/running

Source Code

http://hg.mozilla.org/build/buildapi

Public Interfaces

https://secure.pub.build.mozilla.org/buildapi/ (requires LDAP account with try server commit access or better)
https://secure-pub-build.allizom.org/buildapi/

Current Setup

Buildapi host

NOTE: The production instance is managed by webops and is no longer running on buildapi01.build.mozilla.org as the 'buildapi' user.

There is a cron job that checks for new changes every 5 minutes and deploys them. This instance is exposed to the public behind LDAP auth via proxy from the build.m.o url.

Rabbitmq host

The buildapi instance communicates with a rabbitmq server on rabbit2.build.scl1.mozilla.com. It also connects to two read-only databases (schedulerdb, statusdb) on a slave mysql host maintained by IT.

Self-serve agent hosts

The self-serve agent, which is responsible for performing many of the job requests, is running on bm61, bm62, bm65, bm66 & bm81 (See moco-nodes.pp for details) out of /builds/selfserve-agent. It is a long-running process that waits for messages from the rabbitmq server on cruncher (TODO: double check this), and then makes various DB modifications or pokes at masters' web interfaces. The self-serve agent is started via init, and monitored via nagios.

To modify the list of branches supported by buildapi and self-serve, read ReleaseEngineering/BuildAPI#Maintenance

Informational Requests

As seen on the SelfServe Interface

Results are formatted according to the 'format' query parameter ("?format=html" or "?format=json"). If 'format' is not set, and the 'Accept' header of the request includes 'application/json', the format will be set to json. Otherwise the format will be html.

Will return HTTP 200 for successful queries, or HTTP 404 if a resource is not found.

Job Requests

As seen on the SelfServe Interface

PUT, POST, and DELETE requests (which can be faked by setting a '_method' field to 'PUT' or 'DELETE' in a regular POST request if your client doesn't support PUT/DELETE easiliy) represent requests to change buildbot state. These are called "Job Requests".

Requests to these methods return a job status dictionary, which includes the following keys:

   "status"     - "OK" or "FAILED"
   "msg"        - informational text
   "request_id" - the job request id.  You can find the status of the job
                  by visiting /self-serve/jobs/{job_id}.  This is only set for
                  successfull requests.

Job requests can return 202 (HTTP Accepted) if the request was accepted, or 503 (HTTP Service Unavailable) if there was an error. In case of a 503 error, the request should be re-submitted at a later time.

Missing or bad parameters for the request type will result in a 400 error.

HTTP methodPathDocs
GET/self-serveRoot of the API. You're looking at it!
GET/self-serve/branchesReturn a list of all the branches
GET/self-serve/jobsReturn a list of past self-serve requests
GET/self-serve/jobs/{job_id}Return information about a job request
GET/self-serve/{branch}Return a list of builds running on this branch
POST/self-serve/{branch}/buildRebuild `build_id`, which must be passed in as a POST parameter.

`priority` is also accepted as an optional parameter.
DELETE/self-serve/{branch}/build/{build_id}Cancel the given build
GET/self-serve/{branch}/build/{build_id}Return information about a build
GET/self-serve/{branch}/buildersReturn a list of valid builders for this branch
POST/self-serve/{branch}/builders/{builder_name}/{revision}Creates a new arbitrary build/test for this buildername, for this revision.

Optional POST parameters are 'properties' and 'files', which should be a dictionary and a list, respectively.
POST/self-serve/{branch}/requestRebuild `request_id`, which must be passed in as a POST parameter.

`priority` is also accepted as an optional parameter.
DELETE/self-serve/{branch}/request/{request_id}Cancel the given request
GET/self-serve/{branch}/request/{request_id}Return information about a request
PUT/self-serve/{branch}/request/{request_id}Reprioritize the given request.

Requires `priority` in the POST parameters.

Higher priority values get handled first, and the default priority for
jobs is 0.

Returns a job status message.
DELETE/self-serve/{branch}/rev/{revision}Cancels all running or pending builds on this revision
GET/self-serve/{branch}/rev/{revision}Return a list of builds running for this revision
POST/self-serve/{branch}/rev/{revision}Creates a new build at this revision
GET/self-serve/{branch}/rev/{revision}/is_doneReturn a json dictionary with information about whether the job is
done and has passed all tests for this revision
POST/self-serve/{branch}/rev/{revision}/nightlyCreates a new set of nightly builds at this revision.

`priority` is optional, and if set should be an integer priority.
POST/self-serve/{branch}/rev/{revision}/pgoCreates a new set of PGO builds at this revision.

`priority` is optional, and if set should be an integer priority.
GET/self-serve/{branch}/user/{user}Return a list of builds for this user

Setup Instructions

Described at ReleaseEngineering/BuildAPI