We have a similar need and use the following groovy system:
import hudson.model.* def currentBuild = Thread.currentThread().executable; currentBuild.addAction(new ParametersAction(new StringParameterValue('LAST_BUILD_STATUS', 'FAILURE'))); def buildJob = Hudson.instance.getJob("ArtifactJobName"); def artifacts = buildJob.getLastBuild().getArtifacts(); if (buildJob.getLastBuild().getResult() == Result.SUCCESS && artifacts != null && artifacts.size() > 0) { currentBuild.addAction(new ParametersAction(new StringParameterValue('VARIABLE_NAME', artifacts[0].getFileName()))); currentBuild.addAction(new ParametersAction(new StringParameterValue('LAST_BUILD_STATUS', 'SUCCESS'))); }
This creates a VARIABLE_NAME with the name of the artifact in it from ArtifactJobName , which we use since they are all stored in a specific folder. I'm not sure what will happen if you have multiple artifacts, but it looks like you can get them from an array of artifacts.
You can use getLastSuccessfulBuild to prevent the problem when another ArtifactJobName is currently created and you get an array with a null value.
Stoinov
source share