How to access Hudson artifacts job1 from another job2?

We have production work and night work for the Hudson project. A job should retrieve some artifacts from a specific nightly build # (which is provided as a parameter). Can someone help us with a hint on how to achieve this?

+8
hudson jenkins hudson-api
source share
3 answers

The Copy Artifact plugin seems to be capable of this.

Another approach might be to select an artifact using

http://server/jobs/job1/[build #]/artifacts/ 
+8
source share

You can use the "Environment" configuration tools on the job configuration page. Check the box "Configure additional build levels of M2" and add the "Execute Shell", which grep objects from the desired artifact.

+1
source share

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.

0
source share

All Articles