Search code examples
jenkinsjenkins-workflow

Clean builds with Multibranch Workflow


Using Multibranch Workflow, the command to check out looks like

checkout scm

I can't find a way to tell Jenkins to perform a clean checkout. By "clean," I mean it should remove all files from the workspace that aren't under version control.


Solution

  • I'm not sure if this answers the original question or not (I couldn't tell if the intention was to leave some files in the workspace) but why not just remove the workspace first, this would allow a clean checkout:

    stage ('Clean') {
        deleteDir()
    }
    
    stage ('Checkout') {
        checkout scm 
    }