Skip to content

Instantly share code, notes, and snippets.

@MachinesAreUs
Created May 20, 2015 15:00
Show Gist options
  • Save MachinesAreUs/ec4e0deda23817452c1a to your computer and use it in GitHub Desktop.
Save MachinesAreUs/ec4e0deda23817452c1a to your computer and use it in GitHub Desktop.
Example of how to pass parameters from one job to the next via a file and groovy magic
build_number = build.buildVariableResolver.resolve('PARENT_BUILD_NUMBER')
compile_job = build.buildVariableResolver.resolve('COMPILE_JOB_NAME')
println("Build number: ${build_number}")
println("Compile job: ${compile_job}")
PackagePath = "C:\\Jenkins\\jobs\\"
RutaLog = "$PackagePath\\$compile_job\\builds\\$build_number\\log"
println("Ruta log: ${RutaLog}")
id = "System version is "
file = new File(RutaLog)
file.eachLine { line ->
if (line.contains(id)) {
println(line)
texto = line
texto = texto.replace("System version is : ","")
texto = texto.replace(" ","")
}
}
props = new File("version.properties")
props.write("TEST_ENV="+texto+"\n")
println "Groovy script done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment