summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2016-06-08 21:49:54 +0100
committerFathi Boudra <fathi.boudra@linaro.org>2016-06-09 14:12:18 +0300
commit89a49f645c05e39f376a4be3c1daca31f34d8281 (patch)
treebfdf0bf27790ba394c3cb02a2d07df5673b4afb3
parent90092b1ee699e19da27a571d87c66a23031a4d1b (diff)
downloadpost-build-lava-89a49f645c05e39f376a4be3c1daca31f34d8281.tar.gz
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 <milosz.wasilewski@linaro.org>
-rw-r--r--post-build-lava.groovy25
1 files changed, 25 insertions, 0 deletions
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);
+ }
}