[英]Jenkins trigger build via specific tag
有人可以告诉我如何设置jenkins以基于特定标签从git repo构建吗? 我进行了一些搜索,并尝试设置作业以构建特定的标签,请参阅: Jenkins Git插件:如何构建特定的标签? 但是我只能从master分支中提取最新提交。
这是针对詹金斯2.54。 我已经在SCM下设置了以下内容。
Repo URL and Credentials
name: ref
Refspec: +refs/tags*:refs/remotes/origin/tags/*
Branch Specifier refs/tags/jenkins-test*
在生成触发器下,我允许所有分支触发该作业。 我有一个标记为jenkins-test1.0的提交,当我从gitlab测试webhook时,它成功启动了jenkins作业,但是它从master分支中提取了最新的提交,而不是标记的提交。
提前致谢...
您可以使用通用Webhook触发插件来执行此操作。
从其中一个测试用例中:
场景:应在创建标记时触发构建,而不是在删除标记时触发。
Given the following generic variables are configured:
| variable | expression | expressionType | defaultValue | regexpFilter |
| object_kind | $.object_kind | JSONPath | | |
| before | $.before | JSONPath | | |
| after | $.after | JSONPath | | |
| ref | $.ref | JSONPath | | |
| git_ssh_url | $.repository.git_ssh_url | JSONPath | | |
Given filter is configured with text: $object_kind $before $after
Given filter is configured with expression: ^tag_push\s0{40}\s.{40}$
Given received post content is:
"""
{
"object_kind": "tag_push",
"before": "0000000000000000000000000000000000000000",
"after": "82b3d5ae55f7080f1e6022629cdb57bfae7cccc7",
"ref": "refs/tags/v1.0.0",
"repository":{
"git_ssh_url":"git@example.com:jsmith/example.git",
}
}
"""
Then the job is triggered
Then variables are resolved to:
| variable | value |
| object_kind | tag_push |
| before | 0000000000000000000000000000000000000000 |
| after | 82b3d5ae55f7080f1e6022629cdb57bfae7cccc7 |
| ref | refs/tags/v1.0.0 |
| git_ssh_url | git@example.com:jsmith/example.git |
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.