elo*_*pio 7 jenkins jenkins-pipeline
我已经使用multibranch部署了管道作为代码的docker demo.
它工作正常.我添加了我的github用户名作为组织,当我发出拉取请求时,运行测试.
但是,当某个其他用户发出拉取请求时,也会运行他们的测试.我想手动批准外部贡献者的哪些拉取请求可以在我的jenkins服务器中运行.有没有办法做到这一点?
我可以使用ghprb,但它与管道不兼容,我想将我的作业迁移到管道.
lud*_*nus -2
请尝试在管道脚本中添加这些行:
node('slaveName') {
properties([
parameters([
string(
defaultValue: 'whitelisted1@gmail.com,whitelisted2@gmail.com',
description: 'comma separated whitelisted emails',
name: 'WHITELIST'
)
])
])
def authorEmail
stage('Git') {
authorEmail = sh([
// git log format docs here: https://git-scm.com/docs/pretty-formats
script : "git log -1 --format='%aE'",
returnStdout: true
]).trim()
boolean allowRun = isWhitelisted(env.WHITELIST, authorEmail)
if (allowRun) {
echo "email ${authorEmail} is whitelisted, proceed execution"
} else {
echo "email ${authorEmail} is not in whitelist ${env.WHITELIST}, proceed jenkins job?"
input message: 'Proceed?'
// or just abort build with non-zero shell exit
// currentBuild.result = 'FAILURE'
// sh "exit 10"
}
}
}
}
@NonCPS
boolean isWhitelisted(whitelist, email) {
def res = whitelist.tokenize(" ,;").find { white -> white == email }
return null != res
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
459 次 |
| 最近记录: |