I am trying to activate a pipeline on any merge request change. This works as long as my pipeline script is in Jenkins UI
. Now I outsourced my script on GitLab
, and the checkout should happen via the pipeline via scm option.
But all I get on build (yes, it triggers) is:
java.lang.IllegalArgumentException: Invalid refspec refs/heads/**
This happens if I leave the branch specifier empty, this is because I want to listen to any change. If I specify the branch, the build goes through.
My refspec:
+refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*
Most likely this is a Jenkins bug. https://issues.jenkins-ci.org/browse/JENKINS-46588 There seems to a solution anyway:
In your project configuration under Pipeline -> SCM -> Branches to build -> "Branch Specifier (blank for 'any'): Do not use blank for any or * or .* or **. Use:
*/*
Another workaround would be to disable Lightweight Checkout.
PS: Big thanks to ChrisAnnODell and Omurbek Kadyrbekov for linking the solutions in first place. I'm still a bit puzzled that there is no fix for over 2 years now...
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