Jenkins 多分支管道作业在 Github 拉取请求合并时失败

时间:2021-02-17 21:56:23

标签: jenkins jenkins-pipeline jenkins-plugins multibranch-pipeline jenkins-generic-webhook-trigger

我目前有一个 Jenkins 多分支管道作业设置,其 webhooks 链接到 Github。 我正在使用 Generic Webhook Trigger 插件来监视拉取请求何时关闭合并

发生这种情况时,我希望我的 jenkins 工作采取一些行动。 我遇到的问题是,当拉取请求关闭时,Jenkins 似乎不再能够处理工作。发送 webhook 负载并启动作业,但作业在到达任何阶段之前失败。

ERROR: Could not determine exact tip revision of {{ Pull request }}; falling back to nondeterministic checkout

知道这里发生了什么吗?

示例代码:

# Scripted Pipeline
# Setup Kubernetes container
podTemplate(label: label, containers: [...]) {
  node(label) {
    properties([
      # Generic Webhook Trigger properties
      [$class: 'GenericTrigger',
        genericVariables: [
          [key: 'current_status', value: '$.action'],
          [key: 'merged', value: '$.pull_request.merged']
        ],
        causeString: 'Triggered after a pull request is merged',
        token: 'tokenUsedInWebhook'
      ],
    ])

     stage('Hello World') {
       if (current_status == "closed" && merged == "true") {
         # Do stuff
         println('Pull request was closed and merged. Good job')
       } else {
         println('Pull request is not closed and/or merged yet.')
       }
     }
  }
}

Github 企业版:2.17.18

詹金斯版本:2.263.3

通用网络钩子触发器:1.72

0 个答案:

没有答案