Gogs tag support

My Git repo is on a Gogs server with the drone webhook configured.
When a add a new release, gogs doesn’t trigger the webhook but I opened an issue on the Gogs project.
Then I thought, why not add the tag manually ? Which is what I did and this time, Gogs sent to Drone a tag notification.
Drone didn’t trigger any build so I ran in the webhook configuration and saw that Drone answered a 200 OK to Gogs but with an empty body.
The payload of the request is :

{
“secret”: “xxxxxxxxxxxxxxxxxxxxxxx”,
“ref”: “v9”,
“ref_type”: “tag”,
“repository”: {
“id”: 3,
“owner”: {
“id”: 3,
“username”: “MyOrga”,
“full_name”: “My Orga”,
“email”: “”,
“avatar_url”: “https://gogs.xxx.yyy/avatars/3
},
“name”: “my-project”,
“full_name”: “MyOrga/my-project”,
“description”: “”,
“private”: false,
“fork”: false,
“html_url”: “https://gogs.xxx.yyy/MyOrga/my-project”,
“ssh_url”: “ssh://[email protected]:10022/MyOrga/my-project.git”,
“clone_url”: “https://gogs.xxx.yyy/MyOrga/my-project.git”,
“website”: “”,
“stars_count”: 0,
“forks_count”: 0,
“watchers_count”: 2,
“open_issues_count”: 0,
“default_branch”: “master”,
“created_at”: “2016-01-27T18:10:26+01:00”,
“updated_at”: “2016-11-23T17:09:02+01:00”
},
“sender”: {
“id”: 8,
“username”: “me”,
“full_name”: “Me”,
“email”: “[email protected]”,
“avatar_url”: “https://secure.gravatar.com/avatar/aaaaaaaaaaaaaaaaaaa
}
}

The Drone response has empty body, here are the headers :

Access-Control-Allow-Origin: *
Cache-Control: no-cache, no-store, max-age=0, must-revalidate, value
Content-Length: 0
Content-Type: text/plain; charset=utf-8
Date: Thu, 24 Nov 2016 08:30:48 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Last-Modified: Thu, 24 Nov 2016 08:30:48 GMT
X-Content-Type-Options: nosniff
X-Drone-Version: 0.4.0-beta+0
X-Frame-Options: DENY
X-Xss-Protection: 1; mode=block

Ma .drone.yml file is :

clone:
__skip_verify: true
__tags: true

publish:
__docker-latest:
____image: “plugins/drone-docker”
____registry: ‘artifactory.xxx.yyy:5003’
____insecure: true
____username: drone
____password: $$ARTIFACTORY_PASSWORD
____email: [email protected]
____repo: my-proj
____tag:
______- latest
____when:
______event: push
______branch: master
__docker:
____registry: ‘artifactory.xxx.yyy:5003’
____insecure: true
____username: drone
____password: $$ARTIFACTORY_PASSWORD
____email: [email protected]
____repo: my-proj
____tag:
______- stable
______- “$$TAG”
____when:
______event: tag

(sorry for indent but I could’nt find any better way)

Would you have any hint on what I could do ?
I’m almost sure it has already worked.

I see based on the yaml you are using drone 0.4. Support for Gogs tags were not added until 0.5

I just ran a test with Gogs (latest) and Drone 0.5 (latest), and sadly I have to report that it’s not working.

I have enabled Create webhooks in the repository settings, and enabled Tag Hooks in Drone project settings.

The webhook payload looks like:

{
  "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://[email protected]: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": "[email protected]",
    "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 simply empty and no build is triggered (even though the project has steps for “tag” events).

@mjwwit do you have tags enabled in the repository settings? this is a common root cause for tags not working.

tag support for gogs was merged a few weeks ago, see #1498. This was community contributed and I don’t personally use every feature in drone, so I cannot say for certain that the implementation works. If you don’t think it is working as expected and would like to send a PR that would be much appreciated.

@bradrydzewski Yes, I did enable Tag Hooks in the repository settings.

Has the PR made it’s way to a Docker Hub drone image (0.5 tag) by now? It was merged a month ago, so I’m assuming that’s the case. Either way I’ll make a GH issue and link to the PR. Sadly my Go skills still leave much to be desired, so authoring a PR is not a realistic option for me.

@mjwwit every push to master is published to dockerhub, so there is only about a 10 minute delay between when a PR is merged and when the docker image is updated.

I did a bit of research here and the gogs tag payload does not include a sha. This is a problem for Drone because we need the sha in order to fetch the .drone.yml

We cannot simply fetch the sha for a tag without a decent amount of refactoring. This is not required for GitHub, GitLab or Bitbucket, so it is unlikely we would make an exception and change drone just for Gogs, especially since Gogs has the goal of API and payload compatibility with GitHub.

The Gitea guys already managed to get a PR ready: https://github.com/go-gitea/gitea/pull/300
It’ll be in their 1.0.0 release.