ashwanthkumar / gocd-build-github-pull-requests

GoCD plugin to build PRs for a Github repo
95 stars 72 forks source link

Notification from the notification API #72

Open mrmanc opened 8 years ago

mrmanc commented 8 years ago

Hello

I was wondering whether this plugin hooks in to the Go Notification API (https://api.go.cd/current/#notify-git-materials) to accept published Git events? Or does it always have to poll the GitHub server to work out when a new commit / pull request has happened?

Thanks

ashwanthkumar commented 8 years ago

@mrmanc AFAIK no. From the docs here, I don't know how to hook into it as well.

cc: @arvindsv

arvindsv commented 8 years ago

I took a quick look at the code, and it looks like any pluggable SCM material should be able to use the post commit hook (but in a specific way). The endpoint should be:

POST /go/api/material/notify/scm

The param expected is scm_name and it is matched against the name of the material, in the SCM config. So, the curl is probably something like this (untested):

curl 'https://ci.example.com/go/api/material/notify/scm' \
      -u 'username:password' \
      -H 'Confirm: true' \
      -X POST \
      -d 'scm_name=your-materials-name'

Can you see if that works?

I don't think that will allow you to directly connect a GitHub webhook to GoCD, because of the expectation of the header (Confirm) and the data parameter (scm_name), but it might be a start towards what @mrmanc mentioned in https://github.com/gocd/gocd/issues/217#issuecomment-219497046.

mrmanc commented 8 years ago

Thanks @ashwanthkumar, @arvindsv. Cool, so I understand from that that if we find a way to transform GitHub webhooks into GoCD notifications, then we can use this plugin without generating any more polling activity. Awesome :) I think that wraps up this issue… further discussion can happen in https://github.com/gocd/gocd/issues/217#issuecomment-219497046.

hubx commented 4 years ago

gocd/gocd#217 is closed and we use /go/api/webhooks/github/notify successfully to trigger all our pipelines on our project. We wanted to try PR builds with this cool plugin. However they are only built if we re-enable polling for the Github SCM again.

What do we need to to do to have PR builds working with github webhooks only and without polling? (Polling is limited by our Github Enterprise team)

arvindsv commented 4 years ago

https://github.com/gocd/gocd/issues/8170 finished a few days ago and to be released in 20.9.0 might be relevant.