[JENKINS-18298] Jenkins (Github Plugin) post-commit hook fails to build with ssh config aliases
I have several private GitHub repos that I need to build. I'm using deployment keys and a config file for SSH to let the Jenkins user know what key to use for each repo. In order to get Jenkins to work with GitHub in this fashion, I had to change the repository URL to point to the host alias. So, it looks like:
git@myalias.github.com:myorg/repo.git
This allows me to initiate a build from Jenkins, which is able to checkout the code from github successfully.
I need to initiate builds from GitHub when code is committed. I setup everything and tested the webhook. I saw the payload come in successfully in the logs. When I commit code to the repo, I get the following error: "FINE: Skipped
If I change my repository URL back to git@github.com:myorg/repo.git I get a match on the repo after code commit, but then the jenkins user can't checkout the code from GitHub because it doesn't know what SSH key to use.
Is there a way to get this to work? Thanks.
Originally reported by itarchmerc, imported from: Jenkins (Github Plugin) post-commit hook fails to build with ssh config aliases
- status: Open
- priority: Major
- component(s): github-plugin
- resolution: Unresolved
- votes: 9
- watchers: 14
- imported: 2025-12-08
Raw content of original issue
I have several private GitHub repos that I need to build. I'm using deployment keys and a config file for SSH to let the Jenkins user know what key to use for each repo. In order to get Jenkins to work with GitHub in this fashion, I had to change the repository URL to point to the host alias. So, it looks like:
[email protected]:myorg/repo.git
This allows me to initiate a build from Jenkins, which is able to checkout the code from github successfully.
I need to initiate builds from GitHub when code is committed. I setup everything and tested the webhook. I saw the payload come in successfully in the logs. When I commit code to the repo, I get the following error: "FINE: Skipped <repo> because it doesn't have a matching repository."
If I change my repository URL back to [email protected]:myorg/repo.git I get a match on the repo after code commit, but then the jenkins user can't checkout the code from GitHub because it doesn't know what SSH key to use.
Is there a way to get this to work? Thanks.
- environment:
Ubuntu 12.10
davidcampos:
- Original comment link
Raw content of original comment:
I have the exact same problem. There is any workaround or solution?
Cheers, David
I have the exact same problem.
There is any workaround or solution?
Cheers,
David
tallama:
- Original comment link
Raw content of original comment:
I, too, have this issue. It seems that the plugin should fall back on the Project's top-level GitHub project property and check that as well. Alternatively, the code seems to provide for an override to the hookUrl, but I see no way to configure the override (or even where the method is invoked).
I, too, have this issue. It seems that the plugin should fall back on the Project's top-level GitHub project property and check that as well. Alternatively, the code seems to provide for an override to the hookUrl, but I see no way to configure the override (or even where the method is invoked).
marcofranssen:
- Original comment link
Raw content of original comment:
Same issue on a windows machine. I configured also aliases. They are working when running the job manually. However when pushing code to github it doesn't seem initiate the build.
Same issue on a windows machine. I configured also aliases. They are working when running the job manually. However when pushing code to github it doesn't seem initiate the build.
roaet:
- Original comment link
Raw content of original comment:
Also have this problem. Would like for a fix! I was looking at the code and maybe if we could optionally include the "GitHub project" as a GitHubRepositoryNameContributor we could then ignore aliases and whatnot. If I knew anything about making jenkins plugins I'd test it out for you.
Also have this problem. Would like for a fix! I was looking at the code and maybe if we could optionally include the "GitHub project" as a GitHubRepositoryNameContributor we could then ignore aliases and whatnot. If I knew anything about making jenkins plugins I'd test it out for you.
kstevens:
- Original comment link
Raw content of original comment:
Just got bitten by this, as well. Any workaround or proposed fix?
Just got bitten by this, as well. Any workaround or proposed fix?
aehlke:
- Original comment link
Raw content of original comment:
I too ran into this issue. I'm making a temporary fix in my own fork that just ignores hostname when checking whether a repo matches another given repo, since for us this does not matter.
I think a proper fix has to somehow resolve the hostname to its actual hostname - I looked into this and the only way I can see to do it would be to parse the SSH config file, but that is awful (and there are several files that could set this). There must be a better way, but at this point I'm out of my depth on the solution.
I too ran into this issue. I'm making a temporary fix in my own fork that just ignores hostname when checking whether a repo matches another given repo, since for us this does not matter.
I think a proper fix has to somehow resolve the hostname to its actual hostname - I looked into this and the only way I can see to do it would be to parse the SSH config file, but that is awful (and there are several files that could set this). There must be a better way, but at this point I'm out of my depth on the solution.
aehlke:
- Original comment link
Raw content of original comment:
My fork is here: https://github.com/tophatmonocle/github-plugin/tree/github-1.10-SNAPSHOT-NOHOSTS
My fork is here: https://github.com/tophatmonocle/github-plugin/tree/github-1.10-SNAPSHOT-NOHOSTS
fnaum:
- Original comment link
Raw content of original comment:
One more here with exactly the same problem. Has someone come out with a solution? I can see that this Jira Ticket has not had any updates in more than a year so I think I'll have to have a look at aehlke fork
Not ideal, but I was wondering if adding one more Patter compile here taking into account myalias will work.
something like
Pattern.compile("ssh://git@myalias.([^/]+)/([^/]+)/([^/]+)/?")
One more here with exactly the same problem.
Has someone come out with a solution?
I can see that this Jira Ticket has not had any updates in more than a year so I think I'll have to have a look at aehlke fork
Not ideal, but I was wondering if adding one more Patter compile here taking into account myalias will work.
something like
Pattern.compile("ssh://git@myalias.([^/]+)/([^/]+)/([^/]+)/?")
lps:
- Original comment link
Raw content of original comment:
+1 on this. The github plugin doesn't appear to handle git SSH URLs at all let alone overrides. For example [email protected]:org-name/repo-name is parsed incorrectly as:
host=github.com username=org-name repository=repo-name
This makes it so using the SSH config is required.
+1 on this. The github plugin doesn't appear to handle git SSH URLs at all let alone overrides. For example git@github.com:org-name/repo-name is parsed incorrectly as:
host=github.com
username=org-name
repository=repo-name
This makes it so using the SSH config is required.
[Original is_duplicated_by from Jira: JENKINS-27477]
[Original is_duplicated_by from Jira: JENKINS-31797]
[Original is_duplicated_by from Jira: JENKINS-19463]