From 89a49f645c05e39f376a4be3c1daca31f34d8281 Mon Sep 17 00:00:00 2001 From: Milosz Wasilewski Date: Wed, 8 Jun 2016 21:49:54 +0100 Subject: groovy: added support for calling post-build-reports The jenkins job needs to define boolean variable SKIP_REPORT that is by default set to true. In this case no other job will be called. The job also needs to add post build action of calling parametrized build in case the file post_build_reports_parameters exists. Change-Id: I0e09c097420b4e7fb97b2af02e7da167ff6052ff Signed-off-by: Milosz Wasilewski --- post-build-lava.groovy | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/post-build-lava.groovy b/post-build-lava.groovy index b54b18a..a4ecbd7 100644 --- a/post-build-lava.groovy +++ b/post-build-lava.groovy @@ -61,4 +61,29 @@ if (matcher?.matches()) { lavaJobIdPool += " ${manager.build.number}" parameter.setDefaultValue(lavaJobIdPool) job.save() + + // Call post-build-report with parameters file + def skipReport = manager.build.getEnvironment(manager.listener)['SKIP_REPORT'] + if (!skipReport.toBoolean()) { + def project = manager.build.project; + def pbrParamsCache = "" + + def sourceJob = hudson.model.Hudson.instance.getItem(jobName) + def sourceVariables = sourceJob.getBuildByNumber(upstreamBuild.toInteger()).getEnvironment() + for (sourceVariableName in sourceVariables.keySet()) { + if (sourceVariableName.startsWith("GERRIT")) { + sourceVariableValue = sourceVariables.get(sourceVariableName) + pbrParamsCache += "SOURCE_${sourceVariableName}=${sourceVariableValue}\n"; + } + } + + pbrParamsCache += "SOURCE_PROJECT_NAME=${jobName}\n"; + pbrParamsCache += "SOURCE_BUILD_NUMBER=${upstreamBuild}\n"; + pbrParamsCache += "SOURCE_BUILD_ID=${upstreamBuild}\n"; + pbrParamsCache += "SOURCE_BUILD_URL=${jobUrl}\n"; + pbrParamsCache += "LAVA_JOB_IDS=${lavaJobId}\n"; + + def pbrParams = project.getWorkspace().child("post_build_reports_parameters"); + pbrParams.write(pbrParamsCache, null); + } } -- cgit v1.2.3