[英]Jenkins pipeline trigger on merge to master
I want to setup Jenkins pipeline trigger when PR is merged to master
branch.当 PR 合并到
master
分支时,我想设置 Jenkins 管道触发器。 I have setup Webhook in GitHub repo pointing to Jenkins url http://jenkins.example.com:8080/github-webhook/
and selected following events I have setup Webhook in GitHub repo pointing to Jenkins url
http://jenkins.example.com:8080/github-webhook/
and selected following events
in my Jenkinsfile I use this在我的 Jenkinsfile 我用这个
triggers {
pullRequestReview(reviewStates: ['approved'])
}
But it failed with this error但它失败了这个错误
WorkflowScript: 6: Invalid trigger type "pullRequestReview". Valid trigger types: [upstream, cron, parameterizedCron, GenericTrigger, githubPush, pollSCM] @ line 6, column 9.
If I want to trigger the build when PR is merged to master, what I should user in triggers
?如果我想在 PR 合并到 master 时触发构建,我应该在
triggers
中使用什么?
Here is what you need:这是您需要的:
GenericTrigger(
genericVariables: [
[key: 'action', value: '$.action'],
[key: ‘merged, value: '$.pull_request.merged]
],
causeString: 'Triggered on pr merge,
token: ‘<your-token>’,
printContributedVariables: true,
printPostContent: true,
silentResponse: false,
regexpFilterText: '$action#$merged,
regexpFilterExpression: ‘closed#true'
)
}
And you don't need to select Pull request review comments and Pull request reviews events.而且您不需要 select拉取请求评论评论和拉取请求评论事件。 Just Pull requests is enough for this case.
对于这种情况,只需拉取请求就足够了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.