Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag Hooks not working for Gogs #1870

Closed
mjwwit opened this issue Nov 24, 2016 · 16 comments
Closed

Tag Hooks not working for Gogs #1870

mjwwit opened this issue Nov 24, 2016 · 16 comments
Labels

Comments

@mjwwit
Copy link

mjwwit commented Nov 24, 2016

Tag hook support for Gogs was introduced in #1498 but is not working (anymore).
I tested using the latest Drone 0.5 image from Docker Hub and the latest version of Gogs on Docker Hub.

The Gogs webhook payload is:

{
  "secret": "mysecret",
  "ref": "0.0.5",
  "ref_type": "tag",
  "repository": {
    "id": 84,
    "owner": {
      "id": 3,
      "username": "org",
      "full_name": "Organization",
      "email": "",
      "avatar_url": "https://gogs.somewhere.com/avatars/3"
    },
    "name": "project",
    "full_name": "org/project",
    "description": "Some description",
    "private": true,
    "fork": false,
    "html_url": "https://gogs.somewhere.com/org/project",
    "ssh_url": "ssh://git@gogs.somewhere.com:10022/org/project.git",
    "clone_url": "https://gogs.somewhere.com/org/project.git",
    "website": "",
    "stars_count": 0,
    "forks_count": 0,
    "watchers_count": 7,
    "open_issues_count": 0,
    "default_branch": "master",
    "created_at": "2016-11-24T08:42:01Z",
    "updated_at": "2016-11-24T12:21:33Z"
  },
  "sender": {
    "id": 1,
    "username": "michael",
    "full_name": "Michael de Wit",
    "email": "michael@somewhere.com",
    "avatar_url": "https://gogs.somewhere.com/avatars/1"
  }
}

It also sends the following headers:

X-Gogs-Delivery: asdf-asdf-asdf-asdf
X-Gogs-Event: create

The Drone response is successful (200 OK), but the body is empty and no build is triggered (the project has steps for "tag" events).

Tag Hooks are enabled in the Drone repository settings, and Create hooks are enabled in the Gogs repository settings.

@bradrydzewski
Copy link

I have a patch to improve the tag implementation that I will submit shortly, however, Gogs does not return the sha in the tag hook. This is a problem for Drone because we need a sha in order to fetch the .drone.yml using the Gogs API.

I think we've done as much as we can from the Drone side of things, and now require improvements to the Gogs hook payload to include sha:

{
+ "sha": "940bd336248efae0f9ee5bc7b2d5c985887b16ac",
  "ref": "v1.0.0",
  "ref_type": "tag",
  "repository": {
    "id": 1,
    "owner": {
      "id": 1,
      "username": "gordon",
      "full_name": "Gordon the Gopher",
      "email": "gordon@golang.org",
      "avatar_url": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
    },
    "name": "hello-world",
    "full_name": "gordon/hello-world",
    "description": "",
    "private": true,
    "fork": false,
    "html_url": "http://gogs.golang.org/gordon/hello-world",
    "ssh_url": "git@gogs.golang.org:gordon/hello-world.git",
    "clone_url": "http://gogs.golang.org/gordon/hello-world.git",
    "default_branch": "master",
    "created_at": "2015-10-22T19:32:44Z",
    "updated_at": "2016-11-24T13:37:16Z"
  },
  "sender": {
    "id": 1,
    "username": "gordon",
    "full_name": "Gordon the Gopher",
    "email": "gordon@golang.org",
    "avatar_url": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
  }
}

@tboerger
Copy link

tboerger commented Dec 3, 2016

For gitea we already merged a fix for that, but we can't influence Gogs as unknwon is not available.

@mjwwit
Copy link
Author

mjwwit commented Dec 20, 2016

Before this can be closed, a change is required in Drone.
Drone uses the raw file API of Gogs/Gitea to retrieve the .drone.yml config file, it accesses this API using the following endpoint: GET /repos/:username/:reponame/raw/:ref/:path, but it uses the full git ref as :ref (refs/tags/v1.0.0). Gogs and Gitea only support a short ref (v1.0.0).

See go-gitea/gitea#420 (comment) for details

@bkcsoft
Copy link

bkcsoft commented Dec 20, 2016

I'm not sure why it uses the API for this at all? just regular /:user/:proj/raw/:sha/.drone.yml should work just fine. TBH I'm not sure why gogs/gitea even has this endpoint 😕

@mjwwit
Copy link
Author

mjwwit commented Dec 20, 2016

It may have been part of @bradrydzewski's fix, because the SHA was not included in the webhook payload at first. It's just that it was never going to work because of an incorrect implementation.

As far as I can see, there are two possible solutions now:

  1. Fix the current raw API implementation, correctly using the short ref. The upside of this fix will be that it will also be compatible with Gogs.
  2. Remove usage of the raw API and use the SHA to directly access the file, as suggested by @bkcsoft (provided this also plays nice with private Gogs/Gitea instances). The upside is that this is probably very similar to other Git services, the downside is that Gogs will not work with this, since it's missing a SHA in the payload.

@vtolstov
Copy link

vtolstov commented Dec 20, 2016 via email

@bradrydzewski
Copy link

Fix the current raw API implementation, correctly using the short ref. The upside of this fix will be that it will also be compatible with Gogs.

I prefer this option.

Remove usage of the raw API and use the SHA to directly access the file

The potential problem with this option is Gogs and Gitea will eventually implement application oauth, granting access to API endpoints. For this reason I would prefer the Drone codebase to rely on the API endpoints as much as possible.

@lunny
Copy link

lunny commented Dec 22, 2016

Hi, any work on progress in this issue?

@mjwwit
Copy link
Author

mjwwit commented Dec 22, 2016

@lunny I'm working on a PR

@lunny
Copy link

lunny commented Dec 22, 2016

👍

@HZ89
Copy link

HZ89 commented Dec 23, 2016

tested in my local, fantastic

@MehSha
Copy link

MehSha commented Dec 24, 2016

same issue here with latest gogs 0.9.113 (released yesterday).
not only tag event, but PR and branch create does not work as well.

@bradrydzewski
Copy link

Drone does not support PR or branch create events. It supports push events. Lack of PR support is documented

@MehSha
Copy link

MehSha commented Dec 24, 2016

OK thank you! may be because gogs has delivery on these events, caused me to expect drone to support them!!! sorry!
is that planed to implement? specially on PR that could be very helpful (running tests before merging, for example)

@bradrydzewski
Copy link

There is an open issue for PR support if you want to subscribe to #1605

It is certainly a feature I'd like to see, but unfortunately I have other items I need to focus on right now. Certainly open to contributions, though.

@bradrydzewski
Copy link

merged fix, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants