Jenkins Git Branch not working with Environment Variables

匿名 (未验证) 提交于 2019-12-03 01:38:01

问题:

Folks, There is an environment variable a job is configured with, BRANCH, but when I try configuring git scm with it, i get an error in console

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.

I am 100% certain git is fine, branch exists.

回答1:

Change */${BRANCH} to */$BRANCH, this works for me.

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



回答2:

So under full checkout , Change */${BRANCH} to */$BRANCH, this should read the environment variable.

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

In Pipelines, make sure you aren't specifying a Lightweight Checkout. As of Jenkins 2.73, Lightweight Checkouts will not read the environment variable, but a full checkout will

Check this issue discussion for more details https://github.com/jenkinsci/ghprb-plugin/issues/564



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!