As soon as I attempted to upgrade my Jenkins job to use a parameter for the branch rather than a hard coded value it no longer works.
Have tried many other names than BUILD_BRANCH
Here I've tried ${env.BUILD_BRANCH}, refs/heads${BUILD_BRANCH} and absolutely none of them work When I did this initially I did check lightweight checkout, I removed it after reading many online answers from those having the same problem. Still nothing!. I just added the 'wipe' command to see if that would help but it didn't
error:
> 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)
Thank you for reading even if you couldn't help
Do you have lightweight checkout selected in the Pipeline SCM section? Unchecking lightweight checkout fixed this issue for me.
It seems as if you were mixing configurations (hard to say for sure with just the pieces of images shared).
On one hand, you are defining a parameter (BUILD_BRANCH) to be able to specify which branch should be build.
On another, and assuming that the 2nd image belongs to the Pipeline section of the project configuration, you are trying to use that parameter to limit the branch that should be used to obtain the Jenkinsfile.
That 2nd branch is checked out in a different workspace (different folder) and used only to obtain the Jenkinsfile. Even when you do a full checkout of that, it doesn't mean that you will have the code of that branch available on your workspace.
What you should do, is to use the parameter on your pipeline and feed it to your checkout stage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With