刚开始使用 Jenkins,我似乎无法了解如何正确配置管道的 SCM,因为那里没有 SCM 配置选项卡。我已经向我的 gitlab 项目添加了一个带有 URL 的 webhook
http://my-jenkins-server.com/git/notifyCommit?url=https://my-gitlab-server.com/my-repo.git
但是当我访问该 URL 时,Jenkins 告诉我
No Git consumers using SCM API plugin for: https://my-gitlab-server.com/my-repo.git
这是有道理的,因为我没有明确告诉 Jenkins 我的管道与此存储库相关联,只是隐式地在 Jenkins 脚本中:
stage('Build'){
git url: 'https://my-gitlab-server.com/my-repo.git', branch: 'master', credentialsId: '<some-hash>'
sh 'cd linux-native; make clean all'
}
那么我如何告诉 Jenkins PIPELINE 与特定的存储库相关联?或者,如何找到适合我的管道的 notifyCommit
url?
最佳答案
假设您已启用 Poll SCM选项,Git webhooks 的功能应该与 Freestyle 作业的功能相同。
但是在 /git/notifyCommit
Hook 起作用之前,您需要至少手动运行管道一次。
对于 Freestyle 项目,Jenkins 可以相当轻松地检查作业配置并查看配置了哪个 SCM。对于脚本化管道,Jenkins 在实际执行管道之前无法确定您正在使用的 SCM(如果有)。
关于git - 从 Gitlab webhook 触发 Jenkins 管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42132189/