How to keep Multibranch Pipeline work from cloning repo to master

I have a Multibranch Pipeline job pointing to a Bitbucket server repository.

Before it does anything on the Jenkinsfile, it always makes a full clone of the repository in the master node workspace.

Creates a new workspace with a new clone of the repository for each individual branch.

Not only can this take a significant amount of time for some large repositories, but it also takes up a lot of space on the main node.

Is it possible to do one of the following:

  • Download (and execute) Jenkins file without cloning the full repository
  • Clone a repository on a node other than master
  • Automatic deletion of workspaces of automatically deleted jobs
+3


source to share


1 answer


Found it really annoying. There appears to be no workaround for this problem at this time. To start building, Jenkins requires to Jenkinsfile

be in the repository to get the full repo in order to find it. More information can be found here: JENKINS-33273 Optimize Jenkins branch upload and discovery .

A workaround for the wizard running on the hard drive is to delete the repository copy after the job has completed. Just add this snippet to Jenkinsfile

.



node('master') {
    stage 'Cleanup repository from master node'

    // Due to the MultiPipeLine problem with fetching full repository on the
    // master node we need to manually cleanup the workspace to prevent trashing
    // HDD with copies of the git repository
    def workspace = pwd()
    dir("${workspace}@script") {
        deleteDir()
    }
}

      

0


source







All Articles