Jenkins webhook构建从派生中拉取请求

a64a0gku  于 2022-11-02  发布在  Jenkins
关注(0)|答案(1)|浏览(247)

我们使用bitbucket-push-and-pull-request plugin来构建我们的项目。管道被设置为当webhook被触发时 checkout 源存储库,并且当PR来自源存储库时一切正常。
当pull请求来自forked repo时,会出现无法找到提交的问题,因为仍在fork中。
你知道我们该怎么解决吗
下面是jenkinsfile的一个示例:

pipeline {

  triggers {
    bitBucketTrigger credentialsId: 'GIT_CREDS',
      triggers: [
        [$class: 'BitBucketPPRPullRequestServerTriggerFilter',
          actionFilter: [$class: 'BitBucketPPRPullRequestServerCreatedActionFilter',
            allowedBranches: ''
          ]
        ],
        [$class: 'BitBucketPPRPullRequestServerTriggerFilter',
          actionFilter: [$class: 'BitBucketPPRPullRequestServerMergedActionFilter',
            allowedBranches: ''
          ]
        ],
        [$class: 'BitBucketPPRPullRequestServerTriggerFilter',
          actionFilter: [$class: 'BitBucketPPRPullRequestServerSourceUpdatedActionFilter',
            allowedBranches: ''
          ]
        ]
      ]
  }

  agent any

  stages {
    stage('Checkout Bitbucket repo') {
      steps {
        script {
          git branch: 'env.CHANGE_BRANCH',
            credentialsId: 'GIT_CREDS',
            url: env.GIT_URL
        }
      }
    }
    stage('Start the build') {
      steps {
        script {
            sh 'echo "BUILD"'
        }
      }
    }
  }
}

以下是日志:

stderr: fatal: ambiguous argument '0648334d4491907a45a840a7326c3b8f54180144^{commit}': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
e5nqia27

e5nqia271#

我可以通过在高级选项卡中添加Refspec来修复此问题。
参考规范为:

相关问题