[postgis-tickets] [PostGIS] #3735: Enable Gitea pull requests for Jenkins using web hoos (was: Enable Gitea plugin for Jenkins)

PostGIS trac at osgeo.org
Wed Dec 27 00:44:31 PST 2017


#3735: Enable Gitea pull requests for Jenkins using web hoos
------------------------+----------------------------
  Reporter:  strk       |      Owner:  robe
      Type:  defect     |     Status:  new
  Priority:  medium     |  Milestone:  Management 2.0
 Component:  buildbots  |    Version:  2.3.x
Resolution:             |   Keywords:
------------------------+----------------------------

Comment (by robe):

 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 at 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 at 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 at 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 at 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 at 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 at 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 at 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 at 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.

--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/3735#comment:8>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list