使用deleteDir()

stage("Clean Workspace ") {
			steps{
				sh("ls -al ${env.WORKSPACE}")
					deleteDir()  // clean up current work directory
					sh("ls -al ${env.WORKSPACE}")
				}
			}

完整pipeline

pipeline {
   agent any

options{  timestamps () }


   stages {
      stage('get code ') {
         steps {

          sh("ls -al ${env.WORKSPACE}")
          deleteDir()  // clean up current work directory
          sh("ls -al ${env.WORKSPACE}")

          checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'git@JBr.com:front/DFCc.git']]])   
	 
         }
      }
}
}
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐