Created
April 19, 2016 12:31
-
-
Save toubib/b5d623be6b45ecb7cb992465745817bb to your computer and use it in GitHub Desktop.
Rocket Chat gitlab push event integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Script { | |
process_incoming_request({ | |
request | |
}) { | |
// console is a global helper to improve debug | |
//console.log(request.headers); | |
//console.log(request.content); | |
if (request.content.object_kind === "push") { | |
commits = ''; | |
for (var i = 0; i < request.content.commits.length; i++) { | |
commits += request.content.commits[i].url + ' : ' + request.content.commits[i].message; | |
} | |
return { | |
content: { | |
username: request.content.user_name, | |
text: request.content.user_name + " pushed " + request.content.total_commits_count + " commits to " + request.content.repository.homepage + " .\n" + commits, | |
icon_url: request.content.user_avatar, | |
} | |
}; | |
} | |
return { | |
error: { | |
success: false, | |
message: 'Error example' | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment