Jenkins Pipeline:git 在 Bitbucket Pull Request Builder 触发后检查出错误的修订版本

aaa*_*rgh 5 git bitbucket jenkins

我有一个 Jenkins 管道,它在 Bitbucket 上为我的“引擎”存储库构建和测试拉取请求。我正在使用 Bitbucket Pull Request Builder 插件,该插件检查 PR 分支,对目标分支进行本地合并(使用“构建前合并”管道附加行为),然后在我的 Jenkinsfile 中执行管道。

这些测试具有一些存储在其他存储库中的依赖项。我的 Jenkinsfile 将它们签入子目录(我也尝试将它们签入父目录中的新目录,而不是作为子目录)。

node {
  dir('tools') { git url: 'ssh://git@bitbucket.org:<my_org>/tools.git', branch: 'master', credentialsId: 'my-cred-id' }
}
Run Code Online (Sandbox Code Playgroud)

当此工具签出步骤发生时,git 插件会尝试签出“tools”目录中“engine”存储库的 HEAD 提交:

首先是主“引擎”存储库克隆(在管道开始之前由 Bitbucket 插件触发):

> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git@bitbucket.org:<my_org>/engine.git # timeout=10
Fetching upstream changes from git@bitbucket.org:<my_org>/engine.git
> git --version # timeout=10
using GIT_SSH to set credentials <creds>
> git fetch --tags --progress git@bitbucket.org:<my_org>/engine.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse 2ed413bbaf55^{commit} # timeout=10
> git branch -a -v --no-abbrev --contains 2ed413bbaf551428e5b6328829606155fdb8cd5e # timeout=10
Merging Revision 2ed413bbaf551428e5b6328829606155fdb8cd5e (origin/<branch>) to origin/dev, UserMergeOptions{mergeRemote='origin', mergeTarget='${targetBranch}', mergeStrategy='default', fastForwardMode='--ff'}
> git rev-parse origin/dev^{commit} # timeout=10
> git config core.sparsecheckout # timeout=10
> git checkout -f origin/dev
> git merge --ff 2ed413bbaf551428e5b6328829606155fdb8cd5e # timeout=10
> git rev-parse HEAD^{commit} # timeout=10
Run Code Online (Sandbox Code Playgroud)

然后工具存储库克隆(由git管道中的命令触发):

> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git@bitbucket.org:<my_org>/tools.git # timeout=10
Fetching upstream changes from git@bitbucket.org:<my_org>/tools.git
> git --version # timeout=10
using GIT_SSH to set credentials 
> git fetch --tags --progress git@bitbucket.org:<my_org>/tools.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse 2ed413bbaf55^{commit} # timeout=10
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
hudson.plugins.git.GitException: Command "git rev-parse 2ed413bbaf55^{commit}" returned status code 128:
stdout: 2ed413bbaf55^{commit}

stderr: fatal: ambiguous argument '2ed413bbaf55^{commit}': unknown revision or path not in the working tree.
Run Code Online (Sandbox Code Playgroud)

PR 分支 ( 2ed413) 指向的提交 SHA 与 git 在签出工具存储库时尝试签出的提交 SHA 相同,但该存储库中不存在该提交 SHA。我的管道配置错误吗?或者这是一个错误?