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

Change Jenkins script so it works when pushing/pulling over SSH #242

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@rdicroce

rdicroce commented Jan 15, 2015

The Jenkins post-receive hook doesn't work if you push changesets over SSH (url variable is only populated for HTTP/HTTPS pushes) and it also doesn't work if Jenkins is configured to pull changesets over SSH (the Jenkins Git plugin matches by host + path and the SSH URL has a different path compared to the HTTP/HTTPS URL).

This change resolves both issues.

@gitblit

This comment has been minimized.

Owner

gitblit commented Jan 15, 2015

I'm going to solve this from within Gitblit. Gitblit should be exporting the appropriate URL and it is not.

@rdicroce

This comment has been minimized.

rdicroce commented Jan 15, 2015

Exporting the appropriate URL will fix the problem when a user pushes over SSH, but not the problem when Jenkins is configured to pull over SSH. Either the SSH URL would have to be changed to match the HTTP/HTTPS URL (by adding the "/r" part) or the Jenkins script would have to be changed as I have done so that it calls both variants.

@gitblit

This comment has been minimized.

Owner

gitblit commented Jan 15, 2015

I should have been more clear. Gitblit should be exporting the complete repository url, not just a base url.

@rdicroce

This comment has been minimized.

rdicroce commented Jan 15, 2015

That would also work, but GitBlit would need to export the complete URL for every enabled transport, and the script would need to call all of those URLs. Otherwise the hook won't work if the push occurs with a different transport than than Jenkins is configured with (e.g. developer pushes over HTTP, Jenkins pulls over SSH).

@gitblit

This comment has been minimized.

Owner

gitblit commented Jan 15, 2015

Hmm. Perhaps Jenkins should trigger on a repo name and not a url. Are there alternatives?

@rdicroce

This comment has been minimized.

rdicroce commented Jan 15, 2015

We should maybe discuss with the author of the Jenkins Git plugin. From looking at the code, it actually doesn't match the entire URL, just the host and the path. That's enough to cause a problem with GitBlit because the SSH path is different from the HTTP/HTTPS path.

Jenkins is capable of triggering builds using tokens (this can be done with any source control, it's not part of the Git plugin) but then the user has to explicitly configure a project-specific token on both Jenkins and GitBlit. Not a huge problem I suppose, but it is an extra step and the user has to make sure the token is unique for every project.

@gitblit

This comment has been minimized.

Owner

gitblit commented Dec 23, 2015

The recently merged #986 may offer an alternative solution for this issue. Closing for now.

@gitblit gitblit closed this Dec 23, 2015

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