Banners Plugin
February 12, 2025 ยท View on GitHub
API banners plugin for the Screwdriver API
Usage
Register plugin
const Hapi = require('@hapi/hapi');
const server = new Hapi.Server();
const bannersPlugin = require('./');
server.connection({ port: 3000 });
server.register({
register: bannersPlugin,
options: {}
}, () => {
server.start((err) => {
if (err) {
throw err;
}
console.log('Server running at:', server.info.uri);
});
});
Routes
Create a banner
POST /banners
Arguments
message- Text of the banner to create.type- An optional banner type. Options areinfoandwarn. Defaults toinfoisActive- An optional status flag to indicate whether banner should display. Defaults tofalsescope- An optional scope type that specifies whether the banner should be displayed globally or limited to the affected pipelines or builds. Accepted values areGLOBAL,PIPELINE, andBUILD, withGLOBALas the default.scopeId- A required field when the scope is set toPIPELINEorBUILD, serving as a reference to the corresponding pipeline or build ID.
Example payload:
{
"message": "The Screwdriver Team is currently investigating random failures.",
"type": "info",
"isActive": "true",
"scope": "PIPELINE",
"scopeId": "12345"
}
Get a listing of all banners
Query Params:
scope- Optional Returns banners for a specific scopescopeId- Optional Filters by a specific scope IDcreatedBy- Optional Filters banners created by a specific usertype- Optional Filters by banner typeisActive- Optional Accepts true or false to filter active or inactive banners
GET /banners
GET /banners?scope=GLOBAL&isActive=true&type=info
GET /banners?scope=PIPELINE&scopeId=12345&isActive=true&type=info
Get a specific banner
GET /banners/{id}
Update a specific banner
PUT /banners/{id}
Arguments
message- An optional new string of text for the banner.type- An optional new banner type. Options areinfoandwarnisActive- An optional new status flag to indicate whether banner should display.
Example payload:
{
"message": "The Screwdriver Team has resolved the random failure issue.",
"type": "info",
"isActive": "true"
}
Delete a specific banner
DELETE /banners/{id}