[copyartifacts plugin]copying aritfacts from another job using specific build number passed by environment variable.

357 views
Skip to first unread message

hitesh kumar

unread,
Nov 7, 2013, 2:40:31 AM11/7/13
to jenkins...@googlegroups.com, jenkin...@googlegroups.com

Hi Gang,

Please share your comment/solution on JENKINS-17570

details: how we can use any environment variable as buildnumber of another job to copy artifacts 

i tried suing envinject plugin
but it was failed.

stacktrace below

[EnvInject] - Injecting environment variables from a build step.
[EnvInject] - Injecting as environment variables the properties content
DOWNSTREAM_JOB_BUILD_NUMBER1=$DOWNSTREAM_JOB_BUILD_NUMBER

[EnvInject] - Variables injected successfully.
FATAL: For input string: "$DOWNSTREAM_JOB_BUILD_NUMBER"
java.lang.NumberFormatException: For input string: "$DOWNSTREAM_JOB_BUILD_NUMBER"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at hudson.plugins.copyartifact.SpecificBuildSelector.getBuild(SpecificBuildSelector.java:51)
at hudson.plugins.copyartifact.CopyArtifact.perform(CopyArtifact.java:176)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:697)
at hudson.model.Build$RunnerImpl.build(Build.java:178)
at hudson.model.Build$RunnerImpl.doRun(Build.java:139)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:467)
at hudson.model.Run.run(Run.java:1404)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:238)

Ioannis Moutsatsos

unread,
Mar 4, 2014, 4:13:32 PM3/4/14
to jenkin...@googlegroups.com, jenkins...@googlegroups.com
I've faced the same issue with the Copy Artifacts plugin (which I find very limited)
I ended up writing my own groovy script that can use a reference to a RUN PARAMETER type, the buildURL,  to copy files from a previous build of another project.
I'm attaching the groovy script in case you find it useful.

It takes three parameters (buildURL, artifactFilter, buildFolder) that allow you to copy either from an archived artifact or file parameter and also select the files using a simple filter.
I'm managing the script with the Scriptlet plugin, that allows me to use it as a build step. Works reasonably  well for me.

Perhaps somebody can turn this into a plugin!

Best regards
--Ioannis--
copyRunParameterArtifact.groovy
Reply all
Reply to author
Forward
0 new messages