0

We use docker containers to build all jobs. So we don't have to worry about cleanup workspace, as container goes away with it. But I see $JENKINS_HOME/workspace/_job_name_PR-251-4MSWSIVZHFONFLOHNITFTR6R5CAJMNKESIVZHFONFLOHNITFTR6@script I tried below but did not cleanup

pipeline {
    agent {
        label 'jenkins-slave'
    }
    stages {
        stage('Build') {
            steps {
                sh '''npm install
                npm run build'''
           }
        }
   }
   post { cleanup { cleanWs() } }
}

I can have nightly jenkins job or cron job to delete those directories, looking for better way.

Sourabh
  • 709
  • 1
  • 8
  • 9
  • I think your approach is non standard. It's common to remove the old builds, but the current one's workspace? https://stackoverflow.com/questions/39542485/how-to-write-pipeline-to-discard-old-builds – hakamairi Jul 03 '18 at 12:12
  • 1
    I think to build pull request jenkins uses the $JENKINS_HOME/workspace to temporary checkout code merge and then use pipeline file. Because unless it does this jenkins even don't know on which agent it should build. Anyone using pull request builds may know the situation. – Sourabh Jul 03 '18 at 16:59

0 Answers0