Skip to content

Commit

Permalink
Merge pull request #114 from zotoio/feature/push-handler
Browse files Browse the repository at this point in the history
Feature/push handler
  • Loading branch information
wyvern8 authored Jun 6, 2018
2 parents 6aaf467 + eac793d commit 05ff032
Show file tree
Hide file tree
Showing 10 changed files with 795 additions and 438 deletions.
15 changes: 10 additions & 5 deletions src/agent/AgentUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ export class AgentUtils {
* @param {string} url - Link to more detail
*
*/
static createPullRequestStatus(eventData, state, context, description, url) {
static createEventStatus(eventData, state, context, description, url) {
return {
eventType: eventData.ghEventType,
owner: eventData.repository.owner.login || 'Default_Owner',
repo: eventData.repository.name || 'Default_Repository',
sha: eventData.pull_request.head.sha || 'Missing SHA',
number: eventData.pull_request.number,
sha: eventData.ghEventType === 'pull_request' ? eventData.pull_request.head.sha : eventData.after,
number: eventData.ghEventType === 'pull_request' ? eventData.pull_request.number : '',
state: state,
target_url: url ? url : 'https://github.com/zotoio/github-task-manager',
description: description,
Expand Down Expand Up @@ -183,6 +184,10 @@ export class AgentUtils {
}

static async postResultsAndTrigger(results, message, log) {
// if this is a commit, only add comments for result.
if (results.eventData.pusher && !message.startsWith('Result')) {
return Promise.resolve(true);
}
return AgentUtils.getQueueUrl(process.env.GTM_SQS_RESULTS_QUEUE)
.then(function(sqsQueueUrl) {
let params = {
Expand Down Expand Up @@ -345,11 +350,11 @@ export class AgentUtils {
}

let mapDict = {
'##GHPRNUM##': obj.pull_request.number,
'##GHPRNUM##': obj.pull_request ? obj.pull_request.number : '',
'##GHREPONAME##': obj.repository.name,
'##GH_REPOSITORY_FULLNAME##': obj.repository.full_name,
'##GH_CLONE_URL##': obj.repository.clone_url,
'##GH_PR_BRANCHNAME##': obj.pull_request.head.ref,
'##GH_PR_BRANCHNAME##': obj.pull_request ? obj.pull_request.head.ref : '',
'##PARENTBUILDNUMBER##': this.metaValue(parent, 'buildNumber'),
'##PARENTBUILDNAME##': this.metaValue(parent, 'buildName')
};
Expand Down
Loading

0 comments on commit 05ff032

Please sign in to comment.