diff options
author | Fathi Boudra <fathi.boudra@linaro.org> | 2015-04-30 12:44:28 +0300 |
---|---|---|
committer | Fathi Boudra <fathi.boudra@linaro.org> | 2015-04-30 12:44:28 +0300 |
commit | 9afc03938e4883e2321a4f4e576ffc4f243e391f (patch) | |
tree | 8080875a0fdbaf36c1b54bf33872d1b893197cef | |
parent | a55bf1fd42bbb5316311c3ac6bfb29b5f746f8eb (diff) |
post-build-lava.groovy: fix hardcoded lava server and include 2 new features
* lava server isn't hardcoded anymore since we submit jobs to:
v.l.o, staging.v.l.o and openstack.v.l.o
* add LAVA job id and build job url to the current job
(needed by check lava status)
* update a foreign parameter to store the lava jobs to monitor
Signed-off-by: Fathi Boudra <fathi.boudra@linaro.org>
-rw-r--r-- | post-build-lava.groovy | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/post-build-lava.groovy b/post-build-lava.groovy index 0da6672..8e7d125 100644 --- a/post-build-lava.groovy +++ b/post-build-lava.groovy @@ -1,8 +1,11 @@ +import hudson.model.* + // Add a LAVA job link to the description def matcher = manager.getLogMatcher(".*LAVA Job Id.*") -if(matcher?.matches()) { +if (matcher?.matches()) { def lavaJobId = matcher.group(0).split(",")[0].substring(13) - def lavaJobUrl = "http://validation.linaro.org/scheduler/job/" + lavaJobId + def lavaServer = manager.build.buildVariables.get("LAVA_SERVER").split("/")[0] + def lavaJobUrl = "http://${lavaServer}/scheduler/job/${lavaJobId}" def lavaDescription = " LAVA Job Id: <a href='${lavaJobUrl}'>${lavaJobId}</a>" def cause = manager.build.getAction(hudson.model.CauseAction.class).getCauses() @@ -24,11 +27,29 @@ if(matcher?.matches()) { def jobs = hudson.model.Hudson.instance.getItem(jobName).getAllJobs() for (job in jobs) { - if(job.name == jobConfiguration) { + if (job.name == jobConfiguration) { if (job.getLastBuild().getDescription() != null) { lavaDescription += "<br>" + job.getLastBuild().getDescription() } job.getLastBuild().setDescription(lavaDescription) } } + + // Add parameters + def action = manager.build.getAction(hudson.model.ParametersAction.class) + def parameters = [ + new StringParameterValue("LAVA_JOB_ID", "${lavaJobId}"), + new StringParameterValue("BUILD_JOB", "${jobUrl}") + ] + updatedAction = action.createUpdated(parameters) + manager.build.replaceAction(updatedAction) + + // Update the pool of jobs to monitor + job = hudson.model.Hudson.instance.getItem("check-lava-status") + property = job.getProperty(hudson.model.ParametersDefinitionProperty.class) + parameter = property.getParameterDefinition("LAVA_JOB_ID_POOL") + lavaJobIdPool = parameter.getDefaultValue() + lavaJobIdPool += " ${lavaJobId}" + parameter.setDefaultValue(lavaJobIdPool) + job.save() } |