简体   繁体   English

git stash,jenkins pipeline,没有使用存储库的git工作

[英]git stash, jenkins pipeline, No git jobs using repository

I'm trying to setup triggering a jenkins multibranch pipeline from Atlassian Stash using the stash webhook to jenkins plugin. 我正在尝试使用存储webhook到jenkins插件设置从Atlassian Stash触发jenkins multibranch管道。 My project config has Build Periodically set to @daily, Periodically if not otherwise set to 1 day and I have indexed my branches however when I click on the 'Trigger Jenkins' button on the stash webhook config I get the following error 我的项目配置有定期设置为@daily,定期如果没有设置为1天我已索引我的分支但是当我点击隐藏webhook配置上的'触发詹金斯'按钮时,我得到以下错误

Error: Jenkins response: No git jobs using repository

I have previously read that this could be because polling is disabled on the project however there is no setting to enable it in the top level. 我之前已经读到这可能是因为在项目上禁用了轮询,但是没有设置在顶层启用它。 I have tried enabling it in the master branch Jenkinsfile however it did not show up as checked when I 'View Configuration' for the master job. 我已经尝试在主分支Jenkinsfile中启用它,但是当我为主作业“查看配置”时它没有显示为已检查。 I can also see in the Jenkins logs: 我也可以在Jenkins日志中看到:

no trigger, or post-commit hooks disabled, on my-repo » master

I can't find any other way to get this working? 我找不到任何其他方法让这个工作?

The hint from Jenkins log you see is correct 詹金斯日志提示你看到的是正确的

no trigger, or post-commit hooks disabled, on my-repo » master

The post-commit hook on Jenkins side is disabled by default after job is created without explicitly turning it on. 创建作业后,默认情况下禁用Jenkins端的提交后挂钩,而不显式启用它。 To enable it you should update Build Triggers configuration of the job that you want to be triggered ( my-repo » master in your case) by selecting the following two triggers: 要启用它,您应该通过选择以下两个触发器来更新要Build Triggers的作业的Build Triggers配置(在您的情况下为my-repo » master ):

  1. [✓] Build when a change is pushed to BitBucket [✓] 将更改推送到BitBucket时构建
  2. [✓] Poll SCM ( leave the Schedule text box empty ) [✓] 轮询SCM将“ 计划”文本框保留为空

在此输入图像描述

If you use Jenkins pipeline script instead of Jenkins UI then your Jenkinsfile should contain proper triggers directive (corresponding to the above screen): 如果您使用Jenkins管道脚本而不是Jenkins UI,那么您的Jenkinsfile应包含正确的triggers指令(对应于上面的屏幕):

triggers {
  bitbucketPush()
  pollSCM('') // empty cron expression string
}

The important thing is leaving Schedule field text box empty. 重要的是将Schedule字段文本框留空。 Otherwise, if you enter cron expression there then your build will be triggered twice. 否则,如果您输入cron表达式,那么您的构建将被触发两次。 Once on commit-hook notification and the second one when cron expression trigger gets fired. 一旦发出提交挂钩通知,第二个通知cron表达式触发器被触发。 It's explained by the label placed under the Schedule field: 它由Schedule字段下的标签解释:

No schedules so will only run due to SCM changes if triggered by a post-commit hook 没有时间表只会因为SCM更改而运行,如果由提交后挂钩触发的话

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

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