-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A few tweaks to the new "cleanup" Jenkins file
Looking at the run of the first run, I noticed that seemingly no `yarn--<random number>` or `theia-plugin-download<random identifier>` files were found or cleaned. It was confirmed in the Gitlab ticket that these two types of files are still present on the server. In this commit: - adapt the pattern we use for those two file types - handle the case of the "theia-plugin-download**" files differently, looking-for and deleting individual files that match the pattern rathern than directories. - various little improvements, guided by linter feedback Signed-off-by: Marc Dumais <marc.dumais@ericsson.com>
- Loading branch information
1 parent
073a632
commit 5850adb
Showing
1 changed file
with
48 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,74 @@ | ||
import groovy.json.JsonSlurper | ||
|
||
pipeline { | ||
agent none | ||
agent { | ||
label 'windows' | ||
} | ||
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') | ||
} | ||
} | ||
stage('Cleanup Windows temp directory') { | ||
steps { | ||
script { | ||
listTemp('before cleanup', '%temp%') | ||
cleanFiles('tmp/plugin-download', '%temp%', 'theia-plugin-download**') | ||
cleanDirs('tmp/yarn', '%temp%', 'yarn--**') | ||
cleanDirs('tmp/lighthouse', '%temp%', 'lighthouse.*') | ||
listTemp('after cleanup', '%temp%') | ||
cleanDir('appdata/local/electron', '\"%LocalAppData%\"\\electron\\Cache') | ||
cleanYarnCache('appdata/local/yarn') | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
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\"" | ||
Object listTemp(String label, String temp) { | ||
echo "in listTemp(): ${label}" | ||
bat "DIR ${temp}" | ||
return | ||
} | ||
|
||
bat "echo \"After ${label} Cleanup:\"" | ||
Object cleanFiles(String label, String parent, String pattern) { | ||
echo "in cleanFile() - clean: ${label} files" | ||
echo "parent: ${parent}, pattern: ${pattern}" | ||
|
||
bat "FOR /D /R ${parent} %%i in ${pattern} do echo \"%%i\"" | ||
// use "returnStatus" option to avoid an exception being thrown if no | ||
// matching files are found, failing the pipeline | ||
s = bat( | ||
script: "FORFILES /p ${parent} /m ${pattern} /C \"cmd /c Del /q @file\"", | ||
returnStatus: true | ||
) | ||
if (s != 0) { | ||
echo "No ${pattern} file found... Good I guess" | ||
} | ||
} | ||
|
||
def cleanDir(String label, String parent) { | ||
bat "echo \"Before ${label} Cleanup:\"" | ||
Object cleanDirs(String label, String parent, String pattern) { | ||
echo "Before ${label} Cleanup:" | ||
|
||
bat "FOR /D /R ${parent} %%i in (*) do echo \"%%i\"" | ||
bat "if exist ${parent} @rmdir /s /q ${parent}" | ||
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 (*) do echo \"%%i\"" | ||
echo "After ${label} Cleanup:" | ||
bat "FOR /D /R ${parent} %%i in (${pattern}) do echo \"%%i\"" | ||
return | ||
} | ||
|
||
def cleanYarnCache(String label, String parent) { | ||
bat "echo \"Before ${label} Cleanup:\"" | ||
Object cleanDir(String label, String parent) { | ||
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 "if exist ${parent} @rmdir /s /q ${parent}" | ||
|
||
echo "After ${label} Cleanup:" | ||
bat "FOR /D /R ${parent} %%i in (*) do echo \"%%i\"" | ||
return | ||
} | ||
|
||
Object cleanYarnCache(String label) { | ||
echo "Cleaning-up: ${label}" | ||
sh 'yarn cache clean --all' | ||
return | ||
} | ||
|