Skip to content

Instantly share code, notes, and snippets.

@vmx
Last active April 26, 2016 07:59
Show Gist options
  • Select an option

  • Save vmx/0baa8bc7b63b82e70587f8d24ca1ddba to your computer and use it in GitHub Desktop.

Select an option

Save vmx/0baa8bc7b63b82e70587f8d24ca1ddba to your computer and use it in GitHub Desktop.
Saner file paths on multi-configuration jobs in Jenkins

Configuration

Under "Advanced Project Options" set "Use custom workspace" to:

workspace/${JOB_NAME_SIMPLE}-${GERRIT_BRANCH}${EXECUTOR_NUMBER}

Add the Groovie script under "Prepare an environment for the run" to "Evaluated Groovy script".

// The multi-configuration jobs lead to weird names with `/label_exp=` in them.
// Remove those from the job name to have saner file paths.
def job_name_simple = binding.variables["JOB_NAME"].split("/label_exp")[0]
def manifest_file = ""
switch(binding.variables["GERRIT_BRANCH"]) {
case "master": manifest_file = "branch-master.xml"; break;
case "watson": manifest_file = "watson.xml"; break;
case "sherlock": manifest_file = "sherlock.xml"; break;
case "3.x": manifest_file = "rel-3.0.x.xml"; break;
}
return [
MANIFEST_FILE: manifest_file,
JOB_NAME_SIMPLE: job_name_simpl]e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment