From 6a14fc708b8c3517b818ef20b0cf3963c8558057 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 19 Dec 2017 15:09:26 +0000 Subject: [PATCH] Gitlab support added --- app-backend/src/routes/WebhooksRouter.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app-backend/src/routes/WebhooksRouter.js b/app-backend/src/routes/WebhooksRouter.js index 51d314a..9c53509 100644 --- a/app-backend/src/routes/WebhooksRouter.js +++ b/app-backend/src/routes/WebhooksRouter.js @@ -17,6 +17,7 @@ router.post('/triggerbuild', urlencodedParser, function (req, res, next) { let isGithub = req.header('X-GitHub-Event') === 'push'; let isBitbucket = (req.header('X-Event-Key') === 'repo:push') && req.header('X-Request-UUID') && req.header('X-Hook-UUID'); + let isGitlab = req.header('X-Gitlab-Event') === 'Push Hook'; res.locals.pushedBranches = []; @@ -25,7 +26,7 @@ router.post('/triggerbuild', urlencodedParser, function (req, res, next) { if(refPayload){ req.body = JSON.parse(refPayload); } - let ref = req.body.ref; // "ref/heads/somebranch" + let ref = req.body.ref; // "refs/heads/somebranch" res.locals.pushedBranches.push(ref.substring(11, ref.length)); } else if (isBitbucket) { @@ -33,8 +34,12 @@ router.post('/triggerbuild', urlencodedParser, function (req, res, next) { res.locals.pushedBranches.push(req.body.push.changes[i].new.name); } } - - next(); + else if (isGitlab) { + let ref = req.body.ref; // "refs/heads/somebranch" + res.locals.pushedBranches.push(ref.substring(11, ref.length)); + } + + next(); });