对于给定的脚本化管道(jenkins),管道只能通过 GitLab 的 webhook 触发
应为该管道禁用立即构建
选项。
我们可以配置 Jenkins,以禁用 jenkins 中特定管道脚本作业的Build Now
选项吗?
最佳答案
编辑:这里是带有脚本化管道的解决方案:
node {
def userIdCause = currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause')
stage("Authorize Usage") {
if (userIdCause.size()) {
error('Aborting Build due to manual start - thats not permitted!')
}
}
}
在声明性管道上不使用任何额外插件的以下解决方案怎么样:
pipeline {
...
stages {
stage ("Authorize Usage") {
when { expression { getCause() == "USER" } }
steps {
currentBuild.description = 'Aborting Build due to manual start - thats not permitted!'
error('Aborting Build due to manual start - thats not permitted!')
}
}
...
}
关于jenkins - 如何禁用 "build now"选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55053752/