刚开始使用Jenkins,我似乎无法获得如何为管道正确配置SCM,因为那里没有SCM配置选项卡。我已经在我的gitlab项目中添加了一个webhook,其中包含URL
http://my-jenkins-server.com/git/notifyCommit?url=https://my-gitlab-server.com/my-repo.git
但是当我访问该网址时,Jenkins告诉我
No Git consumers using SCM API plugin for: https://my-gitlab-server.com/my-repo.git
哪种方式有意义,因为我没有明确地告诉Jenkins我的管道与此repo绑定,只是在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'
}
那么我如何告诉詹金斯PIPELINE与特定回购相关联?或者,如何为我的管道找到合适的notifyCommit
网址?
答案 0 :(得分:1)
假设您已启用Poll SCM选项,Git webhooks应该像Freestyle作业一样运作。
但是,在/git/notifyCommit
挂钩工作之前,您需要至少手动运行一次管道。
对于Freestyle项目,Jenkins可以非常轻松地检查作业配置并查看配置的SCM。对于Scripted Pipeline,Jenkins无法确定您使用的SCM(如果有),直到它实际执行管道。
答案 1 :(得分:0)
为使第一个git checkout正常工作并启动管道,我必须明确取消选中“ Lightweight checkout”(在“ Pipeline”下)。