提 PR 时触发 jenkins 构建
Trigger jenkins build when PR is raised
当 github 提出 PR 时,我已经经历了无数次关于触发 Jenkins 构建的 post。
我检查了 jenkins 作业中的 Git hub Pull Request Builder
选项,还提供了 ${sha1}
作为分支。
除了上述之外,我还在我的仓库中添加了 webhook 和 jenkins Github 插件作为服务。
这里还有什么遗漏的。当 PR 提高时,我没有看到构建被触发。
您可以使用 Generic Webhook Trigger Plugin 来做到这一点。
在 GitHub 中设置一个 webhook。
配置 Generic Webhook Trigger Plugin 变量 action 表达式 $.action
将过滤器文本配置为 $action 并将过滤器正则表达式配置为:^(opened|reopened|synchronize)$
现在,只要打开、重新打开或推送新提交,此作业就会 运行。
您还可以从 webhook 中选择其他值,例如:
| variable | expression | expressionType | defaultValue | regexpFilter |
| action | $.action | JSONPath | | |
| pr_id | $.pull_request.id | JSONPath | | |
| pr_state | $.pull_request.state | JSONPath | | |
| pr_title | $.pull_request.title | JSONPath | | |
| pr_from_ref | $.pull_request.head.ref | JSONPath | | |
| pr_from_sha | $.pull_request.head.sha | JSONPath | | |
| pr_from_git_url | $.pull_request.head.repo.git_url | JSONPath | | |
| pr_to_ref | $.pull_request.base.ref | JSONPath | | |
| pr_to_sha | $.pull_request.base.sha | JSONPath | | |
| pr_to_git_url | $.pull_request.base.repo.git_url | JSONPath | | |
| repo_git_url | $.repository.git_url | JSONPath | | |
当 github 提出 PR 时,我已经经历了无数次关于触发 Jenkins 构建的 post。
我检查了 jenkins 作业中的 Git hub Pull Request Builder
选项,还提供了 ${sha1}
作为分支。
除了上述之外,我还在我的仓库中添加了 webhook 和 jenkins Github 插件作为服务。
这里还有什么遗漏的。当 PR 提高时,我没有看到构建被触发。
您可以使用 Generic Webhook Trigger Plugin 来做到这一点。
在 GitHub 中设置一个 webhook。
配置 Generic Webhook Trigger Plugin 变量 action 表达式 $.action
将过滤器文本配置为 $action 并将过滤器正则表达式配置为:^(opened|reopened|synchronize)$
现在,只要打开、重新打开或推送新提交,此作业就会 运行。
您还可以从 webhook 中选择其他值,例如:
| variable | expression | expressionType | defaultValue | regexpFilter |
| action | $.action | JSONPath | | |
| pr_id | $.pull_request.id | JSONPath | | |
| pr_state | $.pull_request.state | JSONPath | | |
| pr_title | $.pull_request.title | JSONPath | | |
| pr_from_ref | $.pull_request.head.ref | JSONPath | | |
| pr_from_sha | $.pull_request.head.sha | JSONPath | | |
| pr_from_git_url | $.pull_request.head.repo.git_url | JSONPath | | |
| pr_to_ref | $.pull_request.base.ref | JSONPath | | |
| pr_to_sha | $.pull_request.base.sha | JSONPath | | |
| pr_to_git_url | $.pull_request.base.repo.git_url | JSONPath | | |
| repo_git_url | $.repository.git_url | JSONPath | | |