Jenkins Git 分支不使用环境变量

Jenkins Git Branch not working with Environment Variables

各位, 作业配置了一个环境变量 BRANCH,但是当我尝试用它配置 git scm 时,我在控制台

中收到错误

Branch Specifier (blank for 'any') */${BRANCH}

git rev-parse refs/remotes/origin/${BRANCH}^{commit} # timeout=10 git rev-parse refs/remotes/origin/origin/${BRANCH}^{commit} # timeout=10 git rev-parse origin/${BRANCH}^{commit} # timeout=10 ERROR: Couldn't find any revision to build.

我 100% 确定 git 没问题,分支存在。

*/${BRANCH} 更改为 */$BRANCH,这对我有用。

分支说明符('any' 为空) */$BRANCH

所以在full checkout下,把*/${BRANCH}改成*/$BRANCH,这样应该会读取环境变量。

分支说明符('any' 为空)*/$BRANCH

在管道中,确保您没有指定轻量级检查。从 Jenkins 2.73 开始,轻量级签出将不会读取环境变量,但完整签出会

查看此问题讨论以获取更多详细信息https://github.com/jenkinsci/ghprb-plugin/issues/564