通过标记现有提交来触发Jenkins管道 [英] Trigger a Jenkins pipeline by tagging an existing commit
问题描述
说明
我已经设置了詹金斯(Jenkins)(2.126),以便在推送新标签时构建管道.具体来说,我想将master
上的现有提交标记为release-3
,并使其触发构建.根据一些消息来源,我想要的是可能的:
I have Jenkins (2.126) set up to build a pipeline when a new tag is pushed. Specifically, I want to tag an existing commit on master
as release-3
and have it trigger a build. According to several sources, what I want is possible:
不幸的是,当我标记一个现有的提交并将其推送到Git存储库时,什么也没有发生.其他构建(由分支触发)可以按预期工作,并且当手动启动时,标记触发的构建成功完成.
Unfortunately, nothing happens when I tag an existing commit and push it to the Git repository. Other builds (triggered by branches) work as expected, and the tag-triggered build in question completes successfully when started manually.
根据某些版本,自2.3版开始,标记触发的管道应该可以使用.我可以进行配置以使其正常工作吗?
According to some, tag-triggered pipelines should work since version 2.3. Is there anything I can configure to make it work?
尝试的屏幕截图
尝试在* * * * *
进行常规管道轮询:
Attempt with a normal pipeline polling at * * * * *
:
尝试使用多分支管道,扫描每个1 minute
:
Attempt with a multibranch pipeline, scanning every 1 minute
:
相关问题
我发现了以下与该问题有关的问题,应该解决.
I found the following issues related to the problem, which is supposed to be resolved.
- https://issues.jenkins-ci.org/browse/JENKINS-38921
- https://issues.jenkins-ci.org/browse/JENKINS-34176
- https://issues.jenkins-ci.org/browse/JENKINS-14917
- https://issues.jenkins-ci.org/browse/JENKINS-47077
- https://issues.jenkins-ci.org/browse/JENKINS-47891
- https://issues.jenkins-ci.org/browse/JENKINS-52376
- https://issues.jenkins-ci.org/browse/JENKINS-38921
- https://issues.jenkins-ci.org/browse/JENKINS-34176
- https://issues.jenkins-ci.org/browse/JENKINS-14917
- https://issues.jenkins-ci.org/browse/JENKINS-47077
- https://issues.jenkins-ci.org/browse/JENKINS-47891
- https://issues.jenkins-ci.org/browse/JENKINS-52376
推荐答案
您可以使用通用Webhook触发插件.
在GitHub中:
- 在GitHub中设置一个Webhook来调用 JENKINS_URL/generic-webhook-trigger/invoke?some-token-here
在詹金斯:
- 创建工作并在触发器"下启用通用触发器
- 使用JSONPath $.ref 配置名为 ref 的变量
- 将过滤器文本设置为 $ ref
- 将过滤器正则表达式设置为 ^(refs/tags/.+)$
- 将令牌设置为此处有令牌
- Create a job and enable the Generic Trigger under "Triggers"
- Configure a variable named ref with JSONPath $.ref
- Set the filter text to $ref
- Set the filter regexp to ^(refs/tags/.+)$
- Set the token to some-token-here
现在,当将标签推送到仓库时,此作业将触发.
Now when a tag is pushed to the repo this job will trigger.
您可能还希望从Webhook中选择其他值,例如 $.repository.ssh_url ,以获取SSH克隆URL.
You may also want to pick other values from the webhook like $.repository.ssh_url to get the SSH clone URL.
这篇关于通过标记现有提交来触发Jenkins管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!