Skip to content

Commit

Permalink
[CI] Clean-up tmp files on Windows agent after CI run
Browse files Browse the repository at this point in the history
* add build job that cleans up temp directory and local app data

Contributed on behalf of STMicroelectronics

Signed-off-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com>
  • Loading branch information
jfaltermeier committed May 17, 2023
1 parent 45be324 commit 073a632
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions cleanup/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import groovy.json.JsonSlurper

pipeline {
agent none
options {
timeout(time: 1, unit: 'HOURS')
disableConcurrentBuilds()
}
stages {
stage('Cleanup') {
parallel {
stage('Cleanup Windows temp directory') {
agent {
label 'windows'
}
steps {
script {
cleanDirs('tmp/yarn', '\"%temp%\"', '(yarn--*)')
cleanDirs('tmp/plugin-download', '\"%temp%\"', '(theia-plugin-download*)')
cleanDirs('tmp/lighthouse', '\"%temp%\"', '(lighthouse.*)')
cleanDir('appdata/local/electron', '\"%LocalAppData%\"\\electron\\Cache')
cleanYarnCache('appdata/local/yarn', '\"%LocalAppData%\"\\Yarn\\Cache')
}
}
}
}
}
}
}

def cleanDirs(String label, String parent, String pattern) {
bat "echo \"Before ${label} Cleanup:\""

bat "FOR /D /R ${parent} %%i in ${pattern} do echo \"%%i\""
bat "FOR /D /R ${parent} %%i in ${pattern} do @rmdir /s /q \"%%i\""

bat "echo \"After ${label} Cleanup:\""

bat "FOR /D /R ${parent} %%i in ${pattern} do echo \"%%i\""
}

def cleanDir(String label, String parent) {
bat "echo \"Before ${label} Cleanup:\""

bat "FOR /D /R ${parent} %%i in (*) do echo \"%%i\""
bat "if exist ${parent} @rmdir /s /q ${parent}"

bat "echo \"After ${label} Cleanup:\""

bat "FOR /D /R ${parent} %%i in (*) do echo \"%%i\""
}

def cleanYarnCache(String label, String parent) {
bat "echo \"Before ${label} Cleanup:\""

bat "FOR /D /R ${parent} %%i in (*) do echo \"%%i\""
sh "yarn cache clean --all"

bat "echo \"After ${label} Cleanup:\""

bat "FOR /D /R ${parent} %%i in (*) do echo \"%%i\""
}

0 comments on commit 073a632

Please sign in to comment.