Skip to content
Browse files
Clone repo with all history and all tags
Intentional changes from JENKINS-43507 have reduced server load, disc
use, and data transfer by honor the refspec which matches the branch of
the job being built in a multi-branch pipeline, and by not fetching tags.

Unfortunately, this branch contains tests which assume it is operating
with a complete clone of the repository, including all tags and all

The tests have been fixed on the master branch, but not on this branch.
Rather than fix the tests on this branch (with the risk that creates),
this change modifies the clone to include all history and all tags.
  • Loading branch information
MarkEWaite committed Jul 27, 2017
1 parent 5847e36 commit 5cff403b221f58106d85edfcaa2d6ae90a1bc9e0
Showing with 14 additions and 1 deletion.
  1. +14 −1 Jenkinsfile
@@ -4,9 +4,22 @@
properties([[$class: 'BuildDiscarderProperty',
strategy: [$class: 'LogRotator', numToKeepStr: '10']]])

def repo=''
def branch="${env.BRANCH_NAME}"

node {
stage('Checkout') {
checkout scm
checkout([$class: 'GitSCM',
branches: [[name: branch]],
browser: [$class: 'GithubWeb', repoUrl: repo],
extensions: [
[$class: 'CloneOption', honorRefspec: false, noTags: false],
[$class: 'LocalBranch', localBranch: '**'],
userRemoteConfigs: [[url: repo]]
echo sh(returnStdout: true, script: 'env')

stage('Build') {

2 comments on commit 5cff403


This comment has been minimized.

Copy link

@betrcode betrcode replied Aug 30, 2017

We solved this by doing

checkout scm
sh('git fetch --tags')

This comment has been minimized.

Copy link
Contributor Author

@MarkEWaite MarkEWaite replied Aug 30, 2017

@betrcode that step will work for linux agents, and for repositories that are publicly accessible.

It won't work for windows agents, and won't work for repositories which require authentication (unless the sh step is wrapped in a withCredentials)

Please sign in to comment.