Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for WORKSPACE_CLEANUP jenkins param in Linux jobs #682

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
43 changes: 42 additions & 1 deletion jenkins-scripts/dsl/_configs_/OSRFLinuxBase.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,47 @@ class OSRFLinuxBase
{
label "docker"

parameters {
booleanParam('WORKSPACE_CLEANUP', true,
'Disable to keep build artifacts in Jenkins for debugging')
}

// No DSL code to support new changes in postBuildScripts, injection DSL
// code directly. https://issues.jenkins.io/browse/JENKINS-66189
configure { project ->
project / 'publishers' / 'org.jenkinsci.plugins.postbuildscript.PostBuildScript' / 'config' {
scriptFiles()
groovyScripts()
buildSteps {
'org.jenkinsci.plugins.postbuildscript.model.PostBuildStep' {
results {
string 'SUCCESS'
string 'NOT_BUILT'
string 'ABORTED'
string 'FAILURE'
string 'UNSTABLE'
}
role('SLAVE')
buildSteps {
'hudson.tasks.Shell' {
command("""\
#!/bin/bash -xe
# Clean up build directory no matter what have happened to the
# build except to test_results
if \${WORKSPACE_CLEANUP} && [ -d \${WORKSPACE}/build ]; then
sudo find \${WORKSPACE}/build -maxdepth 1 -mindepth 1 ! -name test_results -exec rm -rv {} +
echo "Disable WORKSPACE_CLEANUP parameter to avoid cleanup" > \${WORKSPACE}/build_dir_was_cleaned_up
fi
""".stripIndent())
configuredLocalRules()
}
}
}
}
markBuildUnstable(false)
}
}

publishers {
archiveArtifacts {
pattern('Dockerfile')
Expand All @@ -27,8 +68,8 @@ class OSRFLinuxBase
// these files (i.e: testing job). Do not fail if they are not
// present
allowEmpty(true)
}
}
}
}
}
}