Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
branches.

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 5cff403
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Jenkinsfile
Expand Up @@ -4,9 +4,22 @@
properties([[$class: 'BuildDiscarderProperty',
strategy: [$class: 'LogRotator', numToKeepStr: '10']]])

def repo='https://github.com/jenkinsci/git-client-plugin'
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') {
Expand Down

2 comments on commit 5cff403

@betrcode
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We solved this by doing

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

@MarkEWaite
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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