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

WebHook on GitLab does not work #11002

Closed
vanloswang opened this issue Sep 20, 2016 · 6 comments · Fixed by #11031
Closed

WebHook on GitLab does not work #11002

vanloswang opened this issue Sep 20, 2016 · 6 comments · Fixed by #11031

Comments

@vanloswang
Copy link

vanloswang commented Sep 20, 2016

Environment is similar to #10986, just replace Gogs to GitLab, The GitLab server is deployed in a CentOS 7 VM.
Click 'Test Hook' and it returns an error, the error info is as following:

Hook execution failed: {"kind"=>"Status", "apiVersion"=>"v1", "metadata"=>{}, "status"=>"Failure", "message"=>"Internal error occurred: hook failed: missing X-GitHub-Event or X-Gogs-Event", "reason"=>"InternalError", "details"=>{"causes"=>[{"message"=>"hook failed: missing X-GitHub-Event or X-Gogs-Event"}]}, "code"=>500}

It seems like the webhook communication is ok now, but the request header does not contain the key and value for X-GitHub-Event or X-Gogs-Event. So how to let origin works together with GitLab?
The GitLab version is gitlab-ce-8.5.1-ce.0.el7.x86_64 and the settings on GitLab is as following:
image

Version

Origin 1.2

Steps To Reproduce
  1. create a build tempate with github webhook and create a build task
  2. copy the webhook URL, and create a webhook on GitLab
  3. click 'Test Hook' on GitLab
Current Result

failed and show me:

Hook execution failed: {"kind"=>"Status", "apiVersion"=>"v1", "metadata"=>{}, "status"=>"Failure", "message"=>"Internal error occurred: hook failed: missing X-GitHub-Event or X-Gogs-Event", "reason"=>"InternalError", "details"=>{"causes"=>[{"message"=>"hook failed: missing X-GitHub-Event or X-Gogs-Event"}]}, "code"=>500}
Expected Result

success

@vanloswang
Copy link
Author

vanloswang commented Sep 20, 2016

As I know there is a event within GitLab request header named 'X-Gitlab-Event', may be we need to add support for it. a refer is gitlabhq/gitlabhq#8644.

Find the code in ./pkg/build/webhook/github/github.go, maybe we can fix it as following changs:

func getEvent(header http.Header) string {
    event := header.Get("X-GitHub-Event")
    if len(event) == 0 { 
        event = header.Get("X-Gogs-Event")
    }   
    if len(event) == 0 {    
        event = header.Get("X-Gitlab-Event")
    }

    return event
}   

I will test it and push it later.

@jorgemoralespou
Copy link

@vanloswang You should use generic webhook on OpenShift for GitLab

@bparees
Copy link
Contributor

bparees commented Sep 20, 2016

@jorgemoralespou assuming gitlab is matching the github payload, using the github webhook makes sense given all the data we pull off of it.

if gitlab is not matching the github payload then i agree, this is not going to work and shouldn't be merged... i was just assuming it was. perhaps a mistake.

@jorgemoralespou
Copy link

@bparees Didn't see the PR, just saw the issue and my comment was to confirm that GitHub triggers did not work with GitLab and generic webhook was needed. As if the linked PR does fixes that, then I'm happy to have it merged it.
We've been using GitLab for quite some time and have been always needing to use generic webhook. If using the GitHub one provides greater benefit, LGTM.

@vanloswang
Copy link
Author

vanloswang commented Sep 21, 2016

@bparees @jorgemoralespou With this commit, the webhook on gitlab is work well for me now. Both test push on gitlab and git push command will make Origin to auto build the container image.

@shubhamsinha111
Copy link

@vanloswang You should use generic webhook on OpenShift for GitLab

i used generic webhook still got 400 error "Hook executed successfully but returned HTTP 400 {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"missing X-GitHub-Event or X-Gogs-Event","reason":"BadRequest","code":400}"

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

Successfully merging a pull request may close this issue.

5 participants