Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins throws java.lang.IllegalArgumentException: Invalid refspec refs/heads/** Error

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/*
like image 448
AO19 Avatar asked Oct 11 '17 09:10

AO19


1 Answers

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...

like image 90
Tim Malich Avatar answered Oct 30 '22 23:10

Tim Malich