jenkins + bitbucket 实现 pr自动构建及build状态通知
目的:通过pr请求自动检查测试用例执行状态,减少人为点击触发。
1. jenkins 安装插件 Bitbucket Push and Pull Request
注:1. 此插件不可与 Bitbucket plugin 同用,需将 Bitbucket plugin 卸载掉
2. Bitbucket cloud rest api v2.x+ and later (with git and mercurial repos)
Bitbucket server 5.14+ and later (with git repos)
2. bitbucket 中添加webhook
webhook地址: jenkins_url/bitbucket-hook/
配置触发条件:
3.jenkins添加pr 构建配置 ( jenkins pipline中添加trigger)
triggers { bitBucketTrigger( [ [ $class: 'BitBucketPPRPullRequestServerTriggerFilter', actionFilter: [$class: 'BitBucketPPRPullRequestServerCreatedActionFilter', allowedBranches: ''] ], [ $class: 'BitBucketPPRPullRequestServerTriggerFilter', actionFilter: [$class: 'BitBucketPPRPullRequestServerUpdatedActionFilter', allowedBranches: ''] ], [ $class: 'BitBucketPPRRepositoryTriggerFilter', actionFilter: [ $class: 'BitBucketPPRServerRepositoryPushActionFilter', allowedBranches: '', triggerAlsoIfNothingChanged: true, triggerAlsoIfTagPush: false ] ] ] ) }
4. 配置jenkins build状态通知( jenkins 安装 notifier 插件)
jenkins中添加notifier配置
success { echo '构建成功' notifyBitbucket( commitSha1: '', credentialsId: '6', disableInprogressNotification: false, considerUnstableAsSuccess: true, ignoreUnverifiedSSLPeer: true, buildStatus: '', buildName: 'Performance Testing', includeBuildNumberInKey: false, prependParentProjectKey: false, projectKey: '', stashServerBaseUrl: 'https://bitbucket.xxxxx.net') }
bitbucket查看构建状态:
赠人玫瑰,手有余香,如果我的文章有幸能够帮到你,麻烦帮忙点下右下角的推荐,谢谢!
作者: imcati
出处: https://www.cnblogs.com/imcati/>
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出, 原文链接