Skip to content

Allow Concourse to receive git post-commit hooks #331

Closed

Description

@superbeeny

We have GHE admins who are having their deployment of GHE face-melted by some over eager polling and a somewhat large dev organization.

Would it be possible to have concourse accept github post-commit hooks to trigger git-resources? Maybe for other repo resources as well.

Activity

  1. concourse-bot commented on Mar 27, 2016

    @concourse-bot

    Hi there!

    We use Pivotal Tracker to provide visibility into what our team is working on. A story for this issue has been automatically created.

    The current status is as follows:

    • #116419071 Allow Concourse to receive git post-commit hooks

    This comment, as well as the labels on the issue, will be automatically updated as the status in Tracker changes.

  2. arnisoph commented on May 18, 2016

    @arnisoph

    Something generic or easy enhanceable would be great, since I need Gitlab Webhook support, too. :)

  3. vito commented on May 18, 2016

    @vito
    Contributor

    I think this might already work, if you point your webhooks at this endpoint:

    https://github.com/concourse/atc/blob/d54a0cc5ce9a9b9aefb7db4aaca077cb3caf2dd5/routes.go#L110

    The request payload will be entirely ignored, and we'll immediately check for new versions. (This is what you want; it leaves it up to the resource to determine everything rather than some things coming in via hooks and some things being discovered via /check).

    Note that these routes are subject to change (and will change soon as we introduce teams).

  4. superbeeny commented on May 18, 2016

    @superbeeny
    Author

    @vito does trigger still need to be set to true? and would we just set check_every to something really long like 60m

  5. vito commented on May 18, 2016

    @vito
    Contributor

    @superbeeny Yep and yep.

    I definitely don't like the idea of web hooks triggering jobs directly since it totally disregards the resource <-> job abstraction.

  6. vito commented on May 18, 2016

    @vito
    Contributor

    Also that won't quite work since there's no way for us to authorize the request (e.g. GitHub passes a X-Hub-Secret header). Hmm.

  7. arnisoph commented on May 18, 2016

    @arnisoph

    How about an use case?

    • I've changed code in my git repo
    • I git-push to the Github/Gitlab repo
    • I'm creating a PR/MR that triggers a run of the CI pipeline
    • The CI system adds information (comment) to the PR/MR ticket with the report (ran successful or with failures)
    • As a reviewer I can see that status of the code in the PR/MR ticket, without manually opening the concourse CI and search for the job that tested the new code

    This is basically what you can see at saltstack/salt#33328 .

  8. superbeeny commented on May 19, 2016

    @superbeeny
    Author

    @vito I'm going to disagree here, I don't see it as the webhook triggering a job, I see it more as a reverse check, the resource change still triggers the job, only the direction of communication has changed from resource -> github to github -> resource, this still keeps the abstraction in place.

  9. vito commented on Jun 29, 2016

    @vito
    Contributor

    @superbeeny I think we're actually agreeing there - that's what I was saying. 👍

    For the auth issue, I think we can get away with just configuring a resource with an arbitrary token that gets included in the callback URL. All the endpoint does is trigger a check, so we just need to add a basic form of auth in front of it.

  10. DenisIzmaylov commented on Jul 31, 2016

    @DenisIzmaylov

    Great point. We already have a configured Concourse CI with enabled Basic HTTP auth. How we can implement git-commit hooks for GitHub repos? Or worker do it automatically by periodic executing a check script?

  11. vito commented on Jul 31, 2016

    @vito
    Contributor

    @DenisIzmaylov I think we need to do two things:

    • Implement access_token -based auth. This needs some fleshing out, but I think it'd mean adding API endpoints for generating and revoking these tokens, which would just be stored (encrypted) in the database. That encryption strategy should probably be the same as with Using external credential managers for build credentials #291. The actual issue for this is API authentication without using basic auth vmware-archive/atc#42.
    • Add a /api/v1/teams/foo/pipelines/bar/resources/baz/check-hook endpoint which simply authorizes (via access token or anything else really), ignores the entire request payload, and runs a check on the resource. This is very similar to the existing endpoint, but it has to ignore the payload.

    Then just configure GitHub (or whatever service) with the following endpoint:

    https://<external url>/api/v1/teams/foo/pipelines/bar/resources/baz/check-hook?access_token=<token>
    
  12. 33 remaining items

  13. billimek commented on Apr 13, 2017

    @billimek

    By moving away from a single webhook_token: top-level attribute to a more generic webhook: top-value element with multiple parameters, I'm trying to image what other attributes that webhook: would need other than a token?

  14. vito commented on Apr 13, 2017

    @vito
    Contributor

    Agreed; I think a single webhook_token parameter alongside source (not inside of it) makes sense. I don't expect there to be any e.g. GitHub-specific parameters as part of the point of this approach is to implement it generically and not require any knowledge of GitHub's hooks API and such.

    If the time comes that we want more flexibility, we can always change that (backwards-compatibly).

    Shall we continue this discussion in vmware-archive/atc#163 ?

  15. marcosrmendezthd commented on Apr 13, 2017

    @marcosrmendezthd
  16. vito commented on Apr 24, 2017

    @vito
    Contributor
  17. mainephd commented on Apr 24, 2017

    @mainephd

    Thank you for pulling this in @vito

  18. trivigy commented on Apr 17, 2018

    @trivigy

    @vito How come the implementation only allows for triggering the check and not also allow for passing the POST request payload? Could the payload be passed arbitrarily? Like pass a yaml object containing the mothod, url, version, headers, and body of the request to the check?!

  19. vito commented on Apr 18, 2018

    @vito
    Contributor

    @trivigy By passing the payload along we would then require every resource author to have more intimate knowledge of each and every API (GitHub, BitBucket, GitLab). By ignoring it and just running check there's a single eventually-consistent "source of truth" for where the versions are coming from, requiring no change on the part of resource implementors.

  20. trivigy commented on Apr 18, 2018

    @trivigy

    @vito makes total sense from design perspective but should it not be up to the develop to decide the level of involvement? "To use or not to use" - cyber-shakespear ;)

    I am running into a weird problem because of this "double checking" with the https://github.com/jtarchie/github-pullrequest-resource. When I have two commits to the same pull request made very close in time to each other then the actual build, although runs two workers, run the steps on the same commit. The last one. Not running two builds on the two distinct commits. This is because of how the check is being done looking only for the last change.

  21. vito commented on Apr 18, 2018

    @vito
    Contributor

    @trivigy By enabling resource authors to implement multiple ways of detecting versions, it would make it very easy to have inconsistent behavior. By having only one interface, it will always be consistent.

    The GitHub PR resource is fundamentally unsound in its use of the resource interface (which is not the author's fault - it'll take #1707 to implement it properly), and the behavior you've mentioned is only the tip of the iceberg when it comes to funky behavior. With "spaces" done (#1707) it'll be much easier to do what you're attempting.

  22. trivigy commented on Apr 20, 2018

    @trivigy

    @vito is there any other way to pass through meta information from an external source? I am trying to build a github integration (using webhooks) but there is no way for me to "poll" certain pieces of information from github. The only solution is the events api but that one is limited to a single user's vantage point of an organization.

    I feel like one major component that is absolutely missing is meta flow control. The plan in the pipeline dictates how things should happen and when assuming they need to happen. But, the decision of whether they need to happen seems to be placed inside of a check which has no connection to the outside with the exception of polling. Just makes it impossible to create complex integrations without realtime responsiveness to things that happen externally.

  23. fordagertz commented on Jun 28, 2018

    @fordagertz

    Does this solution work with GitHub Enterprise?

  24. billimek commented on Jun 28, 2018

    @billimek
  25. iddm commented on May 24, 2021

    @iddm

    How can I use it in 2021? I see no documentation for this at all. Is there any available on the website in the docs section?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions