diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..5a20fbd --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,5 @@ +image: ubuntu:latest + +job: + script: + - echo "Hello world!" diff --git a/index.js b/index.js index 8c4f986..c68ab92 100644 --- a/index.js +++ b/index.js @@ -35,8 +35,7 @@ var handlers = { if (commits.length < 4) { msg = msg.concat(commits.map(formatCommit)); } else { - msg.push(formatCommit(commits[0])); - msg.push('...'); + msg.push(formatCommit(commits[0]) + ' ...'); msg.push(formatCommit(commits[commits.length - 1])); } @@ -54,8 +53,7 @@ var handlers = { var url = issue.url; var msg = [projectName + ': issue #' + issueNumber + ' has changed state ("' + issueState + '")']; - msg.push(issueTitle); - msg.push(url); + msg.push(issueTitle + ' ' + url); return msg; }, @@ -65,6 +63,8 @@ var handlers = { var request = body.object_attributes; + var projectName = request.target.name; + var from = request.source_branch; var to = request.target_branch; @@ -74,14 +74,28 @@ var handlers = { var state = request.state; var msg = [projectName + ': merge request (' + from + ':' + to + ') #' + id + ' has changed state ("' + state + '")']; - msg.push(title); - msg.push(url); + msg.push(title + ' ' + url); + + return msg; }, build: function(body) { - console.log('build event NYI because not documented'); - console.log(body); - return null; + + var id = body.build_id; + var status = body.build_status; + + var isFinished = body.build_finished_at !== null; + var duration = body.build_duration; + + var projectName = body.project_name; + var stage = body.build_stage; + + var msg = []; + msg.push(projectName + ': build #' + id + ' (' + stage + ') changed status: ' + status); + if (isFinished) + msg.push('build finished in ' + duration + ' seconds. '); + + return msg; } }; @@ -92,6 +106,8 @@ app.post('/', function(req, res) { var msgs = null; if (body.object_kind && handlers[body.object_kind]) msgs = handlers[body.object_kind](body); + else + console.log("Unexpected object_kind:", body.object_kind); if (msgs) { if (msgs instanceof Array) {