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

Add GET requests to webhook #6771

Merged
merged 11 commits into from
May 5, 2019
Merged

Add GET requests to webhook #6771

merged 11 commits into from
May 5, 2019

Conversation

shilch
Copy link
Contributor

@shilch shilch commented Apr 26, 2019

Add option to use GET methods for webhooks to support Jenkins build triggers.

image

@jolheiser
Copy link
Member

jolheiser commented Apr 26, 2019

Pretty sure Jenkins accepts both GET and POST, depending on whether you use a token or other auth? 🤔

EDIT: Tested with curl, definitely accepts both GET and POST requests.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 26, 2019
@shilch
Copy link
Contributor Author

shilch commented Apr 26, 2019

AFAIK the jenkins build trigger doesn't accept POST requests.

@techknowlogick
Copy link
Member

The Gitea Jenkins plugin (https://github.com/jenkinsci/gitea-plugin) has been working successfully for some time now without GET requests.

@shilch
Copy link
Contributor Author

shilch commented Apr 26, 2019

@techknowlogick That plugin is pull-based, i.e. it fetches every x minutes - based on configuration.

@shilch
Copy link
Contributor Author

shilch commented Apr 26, 2019

@jolheiser Can you provide the curl command, please? GET works fine for me, POST does not.

@jolheiser
Copy link
Member

For my instance, I use

curl -X POST https://username:[email protected]/job/project/build

@techknowlogick
Copy link
Member

Seems this plugin also accepts POSTs from Gitea https://wiki.jenkins.io/plugins/servlet/mobile?contentId=106267244#content/view/106267244

@codecov-io
Copy link

codecov-io commented Apr 26, 2019

Codecov Report

Merging #6771 into master will decrease coverage by <.01%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6771      +/-   ##
==========================================
- Coverage   41.18%   41.18%   -0.01%     
==========================================
  Files         424      425       +1     
  Lines       58459    58477      +18     
==========================================
+ Hits        24078    24082       +4     
- Misses      31196    31209      +13     
- Partials     3185     3186       +1
Impacted Files Coverage Δ
models/migrations/migrations.go 1.52% <ø> (ø) ⬆️
modules/auth/repo_form.go 41.73% <ø> (ø) ⬆️
routers/repo/webhook.go 1.39% <0%> (-0.01%) ⬇️
models/migrations/v86.go 0% <0%> (ø)
models/webhook.go 59.83% <65.21%> (-0.34%) ⬇️
modules/avatar/avatar.go 81.25% <0%> (-18.75%) ⬇️
models/repo_list.go 67.89% <0%> (+1.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55a8e12...2b4675a. Read the comment docs.

@shilch
Copy link
Contributor Author

shilch commented Apr 26, 2019

@jolheiser That doesn't trigger any build for me, unfortunately. Only GET requests do, tested it on multiple systems.

@techknowlogick While that might be a solution for most people, I can not add plugins to our systems due to compliance without a lot of hassle. Also, people will probably find GET hooks quite useful for other systems than jenkins.

@jolheiser
Copy link
Member

What version of Jenkins are you using? As far as I can tell I don't have any plugins that added the functionality.
Sorry if this just seems like bikeshedding now, but I'm somewhat curious. Most instructions I find when I Google it seem to recommend POST.

@lunny
Copy link
Member

lunny commented Apr 27, 2019

Some webhook maybe failed when the request body is big enough.

@lafriks lafriks added the type/enhancement An improvement of existing functionality label Apr 27, 2019
@lafriks lafriks added this to the 1.9.0 milestone Apr 27, 2019
@shilch
Copy link
Contributor Author

shilch commented Apr 27, 2019

@jolheiser I'm using the latest one from docker
@lunny @lafriks URLs are unbounded in length:

The HTTP protocol does not place any a priori limit on the length of a URI.

@lunny
Copy link
Member

lunny commented Apr 27, 2019

@shilch The http standard didn't limit that length of GET request but in fact, browsers did that. For Chrome, it's 8182 bytes. See https://stackoverflow.com/questions/2659952/maximum-length-of-http-get-request

@kolaente
Copy link
Member

@lunny I'd say that's not a problem here since we're not dealing with browsers.

models/webhook.go Outdated Show resolved Hide resolved
models/webhook.go Outdated Show resolved Hide resolved
@techknowlogick
Copy link
Member

@kolaente even though we aren't dealing with web browsers, web servers still have max limit on GET request as well. For example if URI is too long nginx will give Error 414: uri too large

@lafriks
Copy link
Member

lafriks commented Apr 27, 2019

Maybe do not send payload with get requests as in such cases most probably it won't be needed anyway

@kolaente
Copy link
Member

kolaente commented Apr 29, 2019

I'd say we should send the payload to be consistent. If the receiving end needs the payload via url, its their responsibility to configure their nginx/apache/whatever appropriate or just use post requests.

This is somewhat of an edge case, so I'd say we do the minimum needed to get this working, as its not our job to fix other peoples broken software.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 2, 2019
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 2, 2019
@lafriks
Copy link
Member

lafriks commented May 2, 2019

GET would be needed to trigger builds etc mostly not to actually use gitea payload data

@kolaente
Copy link
Member

kolaente commented May 3, 2019

@shilch Could you add a setting whether to send payload or not?

@techknowlogick techknowlogick merged commit a2a006a into go-gitea:master May 5, 2019
@techknowlogick techknowlogick mentioned this pull request May 14, 2019
2 tasks
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants