git - 当我使用参数化分支 : fatal: Couldn't find remote ref refs/heads/${BUILD_BRANCH} 时,Jenkins 无法构建

标签 git jenkins gitlab jenkins-cli

一旦我尝试升级我的 Jenkins 作业以使用分支参数而不是硬编码值,它就不再起作用了。
String parameter
尝试了除 BUILD_BRANCH 之外的许多其他名称
enter image description here
在这里,我尝试了 ${env.BUILD_BRANCH}, refs/heads${BUILD_BRANCH} 并且绝对没有一个工作
enter image description here
当我最初这样做时,我确实检查了轻量级 checkout ,在阅读了许多具有相同问题的在线答案后,我将其删除。依然没有!。我刚刚添加了“删除”命令以查看是否有帮助,但没有
错误:

 > git rev-list --no-walk 97428a402f3304a21ccc8df435a40468ebf406c1 # timeout=10
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] readTrusted
[Pipeline] End of Pipeline
hudson.plugins.git.GitException: Command "git fetch --tags --progress --prune -- origin +refs/heads/${BUILD_BRANCH}:refs/remotes/origin/${BUILD_BRANCH}" returned status code 128:
stdout: 
stderr: fatal: Couldn't find remote ref refs/heads/${BUILD_BRANCH}
fatal: The remote end hung up unexpectedly

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2429)
感谢您的阅读,即使您无能为力

最佳答案

您是否在 Pipeline SCM 部分中选择了轻量级 checkout ?取消选中轻量级 checkout 为我解决了这个问题。

关于git - 当我使用参数化分支 : fatal: Couldn't find remote ref refs/heads/${BUILD_BRANCH} 时,Jenkins 无法构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60381036/

相关文章:

Jenkins REST API Auth 使用 URL 参数

具有多个起点的 Jenkins 多分支管道

maven - 如何使用 Kubernetes runner 在 Gitlab 中为 Maven 添加持久卷

GitHub Api 检查 protected 分支上的批准数量

linux - 从 Github 的私有(private)仓库中获取原始文件

git - Email-Ext - 仅向 Git 提交者发送电子邮件

repository - gitlab :import existing repository . 无法正常工作

docker - Docker 和 gitlab-runner 中的 Gitlab CE

git - 无法使用 git clone git ://. 克隆 repo .. - 可以使用 git clone http://

Git 忽略并改变过去