简体   繁体   English

Jenkins GitHub Webhook 未触发构建

[英]Jenkins GitHub Webhook not triggering builds

I have a Jenkins server (2.249) setup and I have connected my GitHub account and tested the connection and it works fine, but for a normal pipeline job where you enter the GitHub repo url, Jenkins seems to add an extra slash at the end?我有一个 Jenkins 服务器 (2.249) 设置,我已经连接了我的 GitHub 帐户并测试了连接并且它工作正常,但是对于您输入 GitHub 存储库 url 的正常管道作业,Jenkins 似乎在末尾添加了一个额外的斜线? So I can't get my normal pipeline job to build on a push event, I've checked the logs and it says:所以我无法让我的正常管道工作建立在推送事件上,我检查了日志,它说:

skipped [repo-name] because it doesn't have a matching repository.

So I've starting to think its because Jenkins is adding an extra slash at the end of my repo url?所以我开始认为这是因为 Jenkins 在我的 repo url 末尾添加了一个额外的斜线? The webhook on the GitHub side works as it gives back a green tick and it works on another multibranch job for push events, just not the normal pipeline jobs. GitHub 端的 webhook 工作,因为它返回一个绿色勾号,并且它在另一个多分支作业上工作以处理推送事件,而不是正常的管道作业。

Don't know if the problem is still on after more than one year but because I've just faced the same issue, here is an answer that help me to understand: https://serverfault.com/a/884717不知道一年多后问题是否仍然存在,但因为我刚刚遇到同样的问题,这里有一个帮助我理解的答案: https://serverfault.com/a/884717

Just to resume the answer : you have to complete the git part (scm) of your Project Configuration:只是为了恢复答案:您必须完成项目配置的 git 部分 (scm): 配置文件

For my part: as the project is a private one, in an organisation that I can't update to add a personal token (as I'm not the owner of the resource - organisation), I choose to use the git+ssh url with a ssh key access to this repo.就我而言:由于该项目是私人项目,在我无法更新以添加个人令牌的组织中(因为我不是资源的所有者 - 组织),我选择使用 git+ssh url使用 ssh 密钥访问此 repo。 The next trick for github is to add the github's IPs to the jenkins user know_hosts file ! github 的下一个技巧是将 github 的 IP 添加到jenkins用户know_hosts文件中!

The reason behind the need to add twice the repository url is obscure.需要添加两次存储库 url 背后的原因是模糊的。 But I could only see that in https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/com/cloudbees/jenkins/GitHubRepositoryNameContributor.java#L113 the method parseAssociatedNames will try to get the Jenkins'job associated names from:但我只能在https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/com/cloudbees/jenkins/GitHubRepositoryNameContributor.java#L113中看到方法parseAssociatedNames将尝试获取Jenkins 的工作相关名称来自:

  • com.cloudbees.jenkins.GitHubRepositoryNameContributor$FromSCM
  • com.cloudbees.jenkins.GitHubTrigger$GitHubRepositoryNameContributorImpl
  • org.jenkinsci.plugins.github_branch_source.GitHubSCMSourceRepositoryNameContributor

I think the third one is for multibranch pipelines.我认为第三个用于多分支管道。 I don't really know for the second but indeed the first one is fromSCM configuration !我真的不知道第二个,但实际上第一个是来自 SCM 配置!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM