Opened 8 years ago

Last modified 7 months ago

#3735 new defect

Enable Gitea pull requests for Jenkins using web hooks

Reported by: strk Owned by: robe
Priority: medium Milestone: Website Management, Bots
Component: QA/buildbots Version:
Keywords: jenkins Cc:

Description (last modified by strk)

See https://plugins.jenkins.io/gitea It should give us the ability for Jenkins to build pull requests sent in Gitea.

Change History (13)

comment:1 by robe, 8 years ago

Milestone: PostGIS 2.3.3Management 2.0

comment:2 by robe, 8 years ago

Looks like we already have it installed version 1.0.6, but latest is 1.0.9. I'll upgrade it and then try to figure out how to use it.

comment:3 by robe, 8 years ago

upgraded to 1.0.9 now to figure out how to use it.

comment:4 by strk, 7 years ago

Description: modified (diff)
Summary: Enable Gogs plugin for JenkinsEnable Gitea plugin for Jenkins

comment:5 by strk, 7 years ago

Now that OSGeo is running Gitea the plugin was updated to Gitea on Debbie. I've added a server configuration but still no idea how to use.

comment:6 by robe, 7 years ago

strk I upgraded Gitea plugin on debbie to latest 1.0.4 (she was running 1.0.3 before).

But I have no clue how to use it.

https://github.com/jenkinsci/gitea-plugin/blob/master/CHANGES.md

the most info is on the changes page. Readme is like just "Readme"

If I understoon gitea web-hooks perhaps the non-existent documentation would make sense :)

All I can gather is yes we can respond to new repo creations and branch pushes so in theory we can flip our svn hooks to gitea web-hooks.

comment:7 by strk, 7 years ago

Feel free to experiment with gitea web-hooks. Right now the "website" and "postgis.net" repositories are using GIT hooks to ping the various Jenkins, but installing GIT hooks requires admin privilege on Gitea (as it means allowing to run arbitrary commands on the server) so it is good to lower that requirement.

comment:8 by robe, 7 years ago

Summary: Enable Gitea plugin for JenkinsEnable Gitea pull requests for Jenkins using web hoos

As mentioned on irc I couldn't get the Jenkins Gitea Plugin to work. It introduced a new kind of job called a Gitea Organization which I tried, but couldn't pull any of the repos so I gave up on it. It sounded too much like GitHub Organization which seems to want to constantly watch the repos. The gogs webhook plugin from what I could tell, doesn't know how to read the web hook post variables, so seemed pretty useless if we ever plan to do Git pull requests.

In the end, I settled on Jenkins generic webhook which once I got the hang of the JSON xpathy thing it had, was much easier to use and it allows me to use any web hook posted variable and also controll the job to trigger if a variable returns something.

The nice thing about the Jenkins generic webhook is we can use it for any system that supports JSON like webhook posts — so Gitea, Gitlab, Gogs

https://wiki.jenkins.io/display/JENKINS/Generic+Webhook+Trigger+Plugin

So one slingshot to kill all my birds (my favorite).

I got the bessies responding to webhooks (and was able to remove bessies from svn hook) and winnie's trunk run to use gitea webhooks. I just changed winnie's 2.4 branch as well ( but haven't had a push to confirm it works).

So next was trying to handle pull requests, but it seems I might not have enough info to handle a pull request from gitea. Which I ticketed here - https://github.com/go-gitea/gitea/issues/3259

I haven't looked at githubs webhooks, but I suspect I have enough to handle those (strk I know you hate hearing that :) ). What I was planning to do was use the git repo reference check out that and then apply the .diff/.patch to the git repo (which works on github but not gitea at moment) and then test that.

I'm going to leave this open until we have the web hook pull issue squared away.

This is what the generic webhook sees from a gitea webhook pull request looks like this:

Generic Cause
[Pipeline] node
GenericWebhookEnvironmentContributor Received:

{
  "secret": "",
  "action": "opened",
  "number": 1,
  "pull_request": {
    "id": 251,
    "url": "",
    "number": 1,
    "user": {
      "id": 3590,
      "login": "robe2",
      "full_name": "",
      "email": "lr@pcorp.us",
      "avatar_url": "https://secure.gravatar.com/avatar/fdeac731da75c06316d72bc9b401b953?d=identicon",
      "username": "robe2"
    },
    "title": "Test Pull",
    "body": "",
    "labels": [],
    "milestone": null,
    "assignee": null,
    "state": "open",
    "comments": 0,
    "html_url": "https://try.gitea.io/robe2/test/pulls/1",
    "diff_url": "https://try.gitea.io/robe2/test/pulls/1.diff",
    "patch_url": "https://try.gitea.io/robe2/test/pulls/1.patch",
    "mergeable": true,
    "merged": false,
    "merged_at": null,
    "merge_commit_sha": null,
    "merged_by": null,
    "base": {
      "label": "master",
      "ref": "master",
      "sha": "393df0dca3594c18324497a033e627e10dbfd288",
      "repo_id": 4435,
      "repo": {
        "id": 4435,
        "owner": {
          "id": 3590,
          "login": "robe2",
          "full_name": "",
          "email": "lr@pcorp.us",
          "avatar_url": "https://secure.gravatar.com/avatar/fdeac731da75c06316d72bc9b401b953?d=identicon",
          "username": "robe2"
        },
        "name": "test",
        "full_name": "robe2/test",
        "description": "test",
        "empty": false,
        "private": false,
        "fork": false,
        "parent": null,
        "mirror": false,
        "size": 24,
        "html_url": "https://try.gitea.io/robe2/test",
        "ssh_url": "git@try.gitea.io:robe2/test.git",
        "clone_url": "https://try.gitea.io/robe2/test.git",
        "website": "",
        "stars_count": 0,
        "forks_count": 0,
        "watchers_count": 1,
        "open_issues_count": 0,
        "default_branch": "master",
        "created_at": "2017-12-25T01:20:32Z",
        "updated_at": "2017-12-25T01:21:14Z",
        "permissions": {
          "admin": false,
          "push": false,
          "pull": false
        }
      }
    },
    "head": {
      "label": "test-pull-1",
      "ref": "test-pull-1",
      "sha": "5fcca2c15d57b3933d67198c2d113a876f466b46",
      "repo_id": 4435,
      "repo": {
        "id": 4435,
        "owner": {
          "id": 3590,
          "login": "robe2",
          "full_name": "",
          "email": "lr@pcorp.us",
          "avatar_url": "https://secure.gravatar.com/avatar/fdeac731da75c06316d72bc9b401b953?d=identicon",
          "username": "robe2"
        },
        "name": "test",
        "full_name": "robe2/test",
        "description": "test",
        "empty": false,
        "private": false,
        "fork": false,
        "parent": null,
        "mirror": false,
        "size": 24,
        "html_url": "https://try.gitea.io/robe2/test",
        "ssh_url": "git@try.gitea.io:robe2/test.git",
        "clone_url": "https://try.gitea.io/robe2/test.git",
        "website": "",
        "stars_count": 0,
        "forks_count": 0,
        "watchers_count": 1,
        "open_issues_count": 0,
        "default_branch": "master",
        "created_at": "2017-12-25T01:20:32Z",
        "updated_at": "2017-12-25T01:21:14Z",
        "permissions": {
          "admin": false,
          "push": false,
          "pull": false
        }
      }
    },
    "merge_base": "393df0dca3594c18324497a033e627e10dbfd288",
    "created_at": "2017-12-25T01:27:27Z",
    "updated_at": "2017-12-25T01:27:27Z"
  },
  "repository": {
    "id": 4435,
    "owner": {
      "id": 3590,
      "login": "robe2",
      "full_name": "",
      "email": "lr@pcorp.us",
      "avatar_url": "https://secure.gravatar.com/avatar/fdeac731da75c06316d72bc9b401b953?d=identicon",
      "username": "robe2"
    },
    "name": "test",
    "full_name": "robe2/test",
    "description": "test",
    "empty": false,
    "private": false,
    "fork": false,
    "parent": null,
    "mirror": false,
    "size": 24,
    "html_url": "https://try.gitea.io/robe2/test",
    "ssh_url": "git@try.gitea.io:robe2/test.git",
    "clone_url": "https://try.gitea.io/robe2/test.git",
    "website": "",
    "stars_count": 0,
    "forks_count": 0,
    "watchers_count": 1,
    "open_issues_count": 0,
    "default_branch": "master",
    "created_at": "2017-12-25T01:20:32Z",
    "updated_at": "2017-12-25T01:21:14Z",
    "permissions": {
      "admin": false,
      "push": false,
      "pull": false
    }
  },
  "sender": {
    "id": 3590,
    "login": "robe2",
    "full_name": "",
    "email": "lr@pcorp.us",
    "avatar_url": "https://secure.gravatar.com/avatar/fdeac731da75c06316d72bc9b401b953?d=identicon",
    "username": "robe2"
  }
}


Contributing variables:

    X_Gitea_Event_0 = pull_request
    BRANCH = master
    X_Gitea_Event = pull_request
    X_Gitea_Delivery_0 = c9247fff-2ca2-48bd-bd4a-7a62e5c46943
    X_Gitea_Delivery = c9247fff-2ca2-48bd-bd4a-7a62e5c46943
    clone_url = https://try.gitea.io/robe2/test.git

I'm guessing gitea passed along an X_GitHub_Event tag so they can impersonate a github request. That said, I suspect I can end up using the same job to handle both github and gitea pull requests. Would be much easier if the diff/patch url worked, but barring that I guess I can fumble thru the whole repository sub node to get what I need.

Anyway thanks strk for the great learning experience. It really has been enjoyable playing with gitea.

Last edited 7 years ago by robe (previous) (diff)

comment:9 by strk, 7 years ago

According to a Gitea developer, since 1.2.0 (we're running 1.3.x) Gitea supports an API to signal status of each commit in each branch of each repository. And chances are that the Jenkins plugin does support such API, so we could be able to setup a proper watcher reporting with automatic badges on each commit. The relative PR includes a screenshot: https://github.com/go-gitea/gitea/pull/1688

Newer Drone should also be supporting it, since this PR was merged (not sure which version): https://github.com/drone/drone/pull/2017

comment:10 by strk, 6 years ago

Just an heads-up: current OSGeo Drone install is already using commit-status reporting (shows a small icon representing CI status for each commit in a PR or in each branch commits page).

I'm not sure reports from multiple sources are supported (ie: dronie and jenkins both reporting on the same commit) — I'm guessing not though…

comment:11 by robe, 4 years ago

Milestone: Management 2.0Website Management, Bots

Milestone renamed

comment:12 by robe, 21 months ago

Looks like this is a bit more mature than before, so will try again - https://plugins.jenkins.io/gitea/

comment:13 by strk, 7 months ago

Keywords: jenkins added
Summary: Enable Gitea pull requests for Jenkins using web hoosEnable Gitea pull requests for Jenkins using web hooks
Version: 2.3.x

Any news about this ?

Note: See TracTickets for help on using tickets.