Hapi builds plugin for the Screwdriver API
const Hapi = require('hapi');
const server = new Hapi.Server();
const buildsPlugin = require('./');
server.connection({ port: 3000 });
server.register({
register: buildsPlugin,
options: {}
}, () => {
server.start((err) => {
if (err) {
throw err;
}
console.log('Server running at:', server.info.uri);
});
});
GET /builds/{id}
GET /builds/{id}/steps/{name}/logs?from=0&pages=10&sort=descending
Arguments:
from
- Line number to start loading lines frompages
- Number of pages to load; a page is 100 linessort
- Order in which to fetch logs (ascending
ordescending
), defaultascending
GET /builds/{id}/steps/{name}
GET /builds/{id}/steps
GET /builds/{id}/steps?status=active
GET /builds/{id}/steps?status=failure
GET /builds/{id}/steps?status=success
PUT /builds/{id}/steps/{name}
Example payload:
{
"code": 0,
"startTime": "2038-01-19T03:15:08.131Z",
"endTime": "2038-01-19T03:15:08.532Z",
"lines": 100
}
POST /builds
Example payload:
{
"jobId": "d398fb192747c9a0124e9e5b4e6e8e841cf8c71c"
}
PUT /builds/{id}
Example payload:
{
"status": "FAILURE"
}
GET /builds/{id}/metrics
GET /builds/{id}/metrics?startTime=2019-02-01T12:00:00.000Z
GET /builds/{id}/metrics?startTime=2019-02-01T12:00:00.000Z&endTime=2019-03-01T12:00:00.000
The server supplies factories to plugins in the form of server app values:
// handler in buildsPlugin.js
handler: (request, reply) => {
const factory = request.server.app.buildFactory;
// ...
}