├── .gitignore ├── host.json ├── README.adoc └── github-event-queue ├── README.adoc ├── function.json └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | *.sw* 2 | build/ 3 | tmp/ 4 | -------------------------------------------------------------------------------- /host.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "af50a7df5e28671e7fa3b8aa7cadddb3" 3 | } 4 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = Analytics Functions 2 | 3 | This repository is a collection of 4 | link:https://azure.microsoft.com/en-us/services/functions/[Azure Functions] 5 | which help the Jenkins project operate. 6 | -------------------------------------------------------------------------------- /github-event-queue/README.adoc: -------------------------------------------------------------------------------- 1 | = GitHub Event Queue 2 | 3 | This function receives 4 | link:https://developer.github.com/webhooks/[GitHub Webhooks] 5 | and shuffles them around for various data processing and analytics purposes. 6 | -------------------------------------------------------------------------------- /github-event-queue/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "bindings": [ 3 | { 4 | "type": "httpTrigger", 5 | "direction": "in", 6 | "name": "req", 7 | "webHookType": "github" 8 | }, 9 | { 10 | "type": "http", 11 | "direction": "out", 12 | "name": "$return" 13 | }, 14 | { 15 | "type": "eventHub", 16 | "name": "outputEventHubMessage", 17 | "path": "github-events", 18 | "connection": "github-events", 19 | "direction": "out" 20 | }, 21 | { 22 | "type": "documentDB", 23 | "name": "outputDocument", 24 | "databaseName": "rtyler-github-events", 25 | "collectionName": "jenkins-infra", 26 | "createIfNotExists": false, 27 | "connection": "rtyler-github-events_DOCUMENTDB", 28 | "direction": "out" 29 | } 30 | ], 31 | "disabled": false 32 | } 33 | -------------------------------------------------------------------------------- /github-event-queue/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Implementation of webhooks processing code for project events, as described 3 | * in IEP-005 which can be found here: 4 | * 5 | */ 6 | 7 | module.exports = function (context, event) { 8 | context.log('JavaScript HTTP trigger function processed a request.'); 9 | 10 | if (event) { 11 | var source = "unknown"; 12 | var event_type = "unknown"; 13 | 14 | if (event_type = context.req.headers['x-github-event']) { 15 | source = "github"; 16 | } 17 | 18 | var record = { 19 | source : source, 20 | type : event_type, 21 | event : event, 22 | received: new Date().toISOString() 23 | }; 24 | 25 | /* enqueue into the EventHub */ 26 | context.bindings.outputEventHubMessage = record; 27 | /* append to the DocumentDB */ 28 | context.bindings.outputDocument = JSON.stringify(record); 29 | 30 | res = { 31 | // status: 200, /* Defaults to 200 */ 32 | body: "Thanks for the event!" 33 | }; 34 | } 35 | context.done(null, res); 36 | }; 37 | --------------------------------------------------------------------------------