Il giorno martedì 3 maggio 2016 01:07:26 UTC+2, [email protected] ha
scritto:
> if I have a job triggering other downstream jobs (as build steps), is
> there a way for the upstream job to get the success/failure status of
> downstream jobs so that I can insert those results into a final email, sent
> at the end of the upstream job?
>
Replying myself... I solved my problem by using a Groovy Postbuild script
(installing the appropriate Jenkins plugin).
I injected a JOBS_RESULTS environment variable into the job, containing the
path to a file where to write downstream job results.
Then added a groovy postbuild like this:
-----------------------
// Get list of triggered downstream jobs
def jobs = manager.getEnvVariable("TRIGGERED_JOB_NAMES")
jobslist = jobs.tokenize(",")
// Get output file name from injected variable, open file, overwrite it
with header
def resultsFile = manager.getEnvVariable("JOBS_RESULTS")
def fp = new File(resultsFile)
fp.write "RESULTS OF TRIGGERED JOBS:\n\n"
def jobResultVar = ""
def jobResult = ""
jobslist.each {
// Get name of result variable for triggered job and then get value
jobResultVar = "TRIGGERED_BUILD_RESULT_" + "$it"
jobResult = manager.getEnvVariable(jobResultVar)
fp << "$it: " + jobResult + "\n"
}
-----------------------
Then used the Extended Email plugin to send an email including this macro
in the mail body:
${FILE, path="$JOBS_RESULTS"}
The job needs to run on the master, as the groovy script only runs on the
master and so the email plugin would not find the file otherwise.
Maybe it can be useful to someone else.
Bye,
01
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/d54a376d-f4d7-403d-95ba-186442992e11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.