Merge branch 'test' into 'master'
add project name for a merge request This fixes a bug. See merge request !2
This commit is contained in:
commit
1d1ef54c98
5
.gitlab-ci.yml
Normal file
5
.gitlab-ci.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
image: ubuntu:latest
|
||||||
|
|
||||||
|
job:
|
||||||
|
script:
|
||||||
|
- echo "Hello world!"
|
34
index.js
34
index.js
@ -35,8 +35,7 @@ var handlers = {
|
|||||||
if (commits.length < 4) {
|
if (commits.length < 4) {
|
||||||
msg = msg.concat(commits.map(formatCommit));
|
msg = msg.concat(commits.map(formatCommit));
|
||||||
} else {
|
} else {
|
||||||
msg.push(formatCommit(commits[0]));
|
msg.push(formatCommit(commits[0]) + ' ...');
|
||||||
msg.push('...');
|
|
||||||
msg.push(formatCommit(commits[commits.length - 1]));
|
msg.push(formatCommit(commits[commits.length - 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,8 +53,7 @@ var handlers = {
|
|||||||
var url = issue.url;
|
var url = issue.url;
|
||||||
|
|
||||||
var msg = [projectName + ': issue #' + issueNumber + ' has changed state ("' + issueState + '")'];
|
var msg = [projectName + ': issue #' + issueNumber + ' has changed state ("' + issueState + '")'];
|
||||||
msg.push(issueTitle);
|
msg.push(issueTitle + ' ' + url);
|
||||||
msg.push(url);
|
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
},
|
},
|
||||||
@ -65,6 +63,8 @@ var handlers = {
|
|||||||
|
|
||||||
var request = body.object_attributes;
|
var request = body.object_attributes;
|
||||||
|
|
||||||
|
var projectName = request.target.name;
|
||||||
|
|
||||||
var from = request.source_branch;
|
var from = request.source_branch;
|
||||||
var to = request.target_branch;
|
var to = request.target_branch;
|
||||||
|
|
||||||
@ -74,14 +74,28 @@ var handlers = {
|
|||||||
var state = request.state;
|
var state = request.state;
|
||||||
|
|
||||||
var msg = [projectName + ': merge request (' + from + ':' + to + ') #' + id + ' has changed state ("' + state + '")'];
|
var msg = [projectName + ': merge request (' + from + ':' + to + ') #' + id + ' has changed state ("' + state + '")'];
|
||||||
msg.push(title);
|
msg.push(title + ' ' + url);
|
||||||
msg.push(url);
|
|
||||||
|
return msg;
|
||||||
},
|
},
|
||||||
|
|
||||||
build: function(body) {
|
build: function(body) {
|
||||||
console.log('build event NYI because not documented');
|
|
||||||
console.log(body);
|
var id = body.build_id;
|
||||||
return null;
|
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;
|
var msgs = null;
|
||||||
if (body.object_kind && handlers[body.object_kind])
|
if (body.object_kind && handlers[body.object_kind])
|
||||||
msgs = handlers[body.object_kind](body);
|
msgs = handlers[body.object_kind](body);
|
||||||
|
else
|
||||||
|
console.log("Unexpected object_kind:", body.object_kind);
|
||||||
|
|
||||||
if (msgs) {
|
if (msgs) {
|
||||||
if (msgs instanceof Array) {
|
if (msgs instanceof Array) {
|
||||||
|
Loading…
Reference in New Issue
Block a user