Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Bitbucket Team/Project job doesn't fetch tags anymore

Tags:

jenkins

I have a Jenkins Bitbucket Team/Project job. Inside the Jenkinsfile in my repository I use "git describe" to get the current tag. After I updated to the latest Jenkins version (2.60.3) and updated most plugins, this fails because Jenkins doesn't fetch tags anymore.

This is what I had before the update:

Branch event
Checking out git https://bitbucket.org/xxxxxxx to read Jenkinsfile
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://bitbucket.org/xxxxx.git # timeout=10
Fetching upstream changes from https://bitbucket.org/xxxx.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials Admin user to clone bitbucket repositories
 > git fetch --tags --progress https://bitbucket.org/xxxxx.git +refs/heads/master

This is what I have now:

Branch event
Checking out git https://bitbucket.org/xxxx.git into /var/lib/jenkins/jobs/xxxx/jobs/xxx/branches/master/workspace@script to read Jenkinsfile
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository https://bitbucket.org/xxxxx.git
 > git init /var/lib/jenkins/jobs/xxx/jobs/xxxx/branches/master/workspace@script # timeout=10
Fetching upstream changes from https://bitbucket.org/xxx.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials Admin user to clone bitbucket repositories
 > git fetch --no-tags --progress https://bitbucket.org/xxxx.git +refs/heads/master:refs/remotes/origin/master

This is the plugins I have installed:

  • Bitbucket Branch Source Plugin 2.2.3
  • Bitbucket Plugin 1.1.5
  • Git Client plugin 2.5.0
  • Git plugin 3.5.1

The default behaviour changed. It's not fetching tags anymore (uses --no-tags). I couldn't find any settings to force jenkins to fetch tags. In Bitbucket Team/Project settings, you can setup "Advanced clone behaviours":

  • Shallow clone
  • ...
  • Do not fetch tags

"Do not fetch tags" is not selected. So I'd think that it should fetch tags by default...

Anyone having similar issue? How can I force Jenkins to fetch tags in a Bitbucket Team/Project job?

like image 258
Benjamin Bertrand Avatar asked Sep 01 '17 09:09

Benjamin Bertrand


1 Answers

I created a Jenkins issue and got some explanations (thanks to Stephen Connolly): https://issues.jenkins-ci.org/browse/JENKINS-46736

The solution is just to add the "Advanced Clone Behaviours" and to leave "Do not fetch tags" unchecked.

like image 58
Benjamin Bertrand Avatar answered Nov 23 '22 02:11

Benjamin Bertrand