From c7ca1974f53483b5c1ad65e5d38a8c2b63f0d7be Mon Sep 17 00:00:00 2001 From: tomaslin Date: Fri, 5 Feb 2016 10:51:29 -0800 Subject: [PATCH 1/2] fix the way we get repo project from stash event --- .../spinnaker/echo/controllers/WebhooksController.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/echo-webhooks/src/main/groovy/com/netflix/spinnaker/echo/controllers/WebhooksController.groovy b/echo-webhooks/src/main/groovy/com/netflix/spinnaker/echo/controllers/WebhooksController.groovy index 88fb12fda..af9dffbd4 100644 --- a/echo-webhooks/src/main/groovy/com/netflix/spinnaker/echo/controllers/WebhooksController.groovy +++ b/echo-webhooks/src/main/groovy/com/netflix/spinnaker/echo/controllers/WebhooksController.groovy @@ -45,7 +45,7 @@ class WebhooksController { if (type == 'git' && source == 'stash') { event.content.hash = postedEvent.refChanges?.first().toHash event.content.branch = postedEvent.refChanges?.first().refId.replace('refs/heads/', '') - event.content.repoProject = postedEvent.repository.project + event.content.repoProject = postedEvent.repository.project.key event.content.slug = postedEvent.repository.slug } From 17906dee88f05e310022c60e2243c26c062e951c Mon Sep 17 00:00:00 2001 From: tomaslin Date: Fri, 5 Feb 2016 13:08:43 -0800 Subject: [PATCH 2/2] convert github event type --- .../echo/controllers/WebhooksController.groovy | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/echo-webhooks/src/main/groovy/com/netflix/spinnaker/echo/controllers/WebhooksController.groovy b/echo-webhooks/src/main/groovy/com/netflix/spinnaker/echo/controllers/WebhooksController.groovy index af9dffbd4..446254657 100644 --- a/echo-webhooks/src/main/groovy/com/netflix/spinnaker/echo/controllers/WebhooksController.groovy +++ b/echo-webhooks/src/main/groovy/com/netflix/spinnaker/echo/controllers/WebhooksController.groovy @@ -42,11 +42,19 @@ class WebhooksController { event.details.type = type event.content = postedEvent - if (type == 'git' && source == 'stash') { - event.content.hash = postedEvent.refChanges?.first().toHash - event.content.branch = postedEvent.refChanges?.first().refId.replace('refs/heads/', '') - event.content.repoProject = postedEvent.repository.project.key - event.content.slug = postedEvent.repository.slug + if (type == 'git') { + if (source == 'stash') { + event.content.hash = postedEvent.refChanges?.first().toHash + event.content.branch = postedEvent.refChanges?.first().refId.replace('refs/heads/', '') + event.content.repoProject = postedEvent.repository.project.key + event.content.slug = postedEvent.repository.slug + } + if (source == 'github') { + event.content.hash = postedEvent.after + event.content.branch = postedEvent.ref.replace('refs/heads/', '') + event.content.repoProject = postedEvent.repository.owner.name + event.content.slug = postedEvent.repository.name + } } log.info("Webhook ${source}:${type}:${event.content}")