Skip to content

Commit

Permalink
Add ability to use ram disk for jenkins workspace (elastic#47746)
Browse files Browse the repository at this point in the history
* Add ability to use ram disk for jenkins workspace

* Re-combine ciGroup agents

* Address some PR feedback / questions

* Add --preserve-root
  • Loading branch information
brianseeders committed Oct 18, 2019
1 parent 00b0b4b commit 25bc4ea
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ stage("Kibana Pipeline") { // This stage is just here to help the BlueOcean UI a
'oss-ciGroup4': getOssCiGroupWorker(4),
'oss-ciGroup5': getOssCiGroupWorker(5),
'oss-ciGroup6': getOssCiGroupWorker(6),
]),
'kibana-oss-agent2': withWorkers('kibana-oss-tests2', { buildOss() }, [
'oss-ciGroup7': getOssCiGroupWorker(7),
'oss-ciGroup8': getOssCiGroupWorker(8),
'oss-ciGroup9': getOssCiGroupWorker(9),
Expand All @@ -34,8 +32,6 @@ stage("Kibana Pipeline") { // This stage is just here to help the BlueOcean UI a
'xpack-ciGroup3': getXpackCiGroupWorker(3),
'xpack-ciGroup4': getXpackCiGroupWorker(4),
'xpack-ciGroup5': getXpackCiGroupWorker(5),
]),
'kibana-xpack-agent2': withWorkers('kibana-xpack-tests2', { buildXpack() }, [
'xpack-ciGroup6': getXpackCiGroupWorker(6),
'xpack-ciGroup7': getXpackCiGroupWorker(7),
'xpack-ciGroup8': getXpackCiGroupWorker(8),
Expand All @@ -60,7 +56,7 @@ stage("Kibana Pipeline") { // This stage is just here to help the BlueOcean UI a

def withWorkers(name, preWorkerClosure = {}, workerClosures = [:]) {
return {
jobRunner('tests-xl') {
jobRunner('tests-xl', true) {
try {
doSetup()
preWorkerClosure()
Expand Down Expand Up @@ -151,7 +147,7 @@ def legacyJobRunner(name) {
withEnv([
"JOB=${name}",
]) {
jobRunner('linux && immutable') {
jobRunner('linux && immutable', false) {
try {
runbld('.ci/run.sh', true)
} finally {
Expand All @@ -172,8 +168,21 @@ def legacyJobRunner(name) {
}
}

def jobRunner(label, closure) {
def jobRunner(label, useRamDisk, closure) {
node(label) {
if (useRamDisk) {
// Move to a temporary workspace, so that we can symlink the real workspace into /dev/shm
def originalWorkspace = env.WORKSPACE
ws('/tmp/workspace') {
sh """
mkdir -p /dev/shm/workspace
mkdir -p '${originalWorkspace}' # create all of the directories leading up to the workspace, if they don't exist
rm --preserve-root -rf '${originalWorkspace}' # then remove just the workspace, just in case there's stuff in it
ln -s /dev/shm/workspace '${originalWorkspace}'
"""
}
}

def scmVars = checkout scm

withEnv([
Expand Down

0 comments on commit 25bc4ea

Please sign in to comment.