How do I copy artifacts to the Jinkins build pipeline?
Is there any documentation / examples in the Copy artifacts plugin , namely the "Specified by build parameter" option?
I'm trying to do a "join-diamond" pipeline like this SO question and can't figure out what to put in a Parameter Name
variant of the "Copy artifacts from another project" step to copy my artifacts correctly.
All my assignments have a parameter PL_BUILD_NUMBER
and I would like to use that to select which assembly to copy from artifacts.
This mailing list advises that the parameter must be XML. So I tried this:
BUILD_SELECTOR=<SpecificBuildSelector><buildNumber>$PL_BUILD_NUMBER</buildNumber></SpecificBuildSelector>
but it didn't work. I am getting this exception in the log:
java.lang.NullPointerException
at java.io.StringReader.<init>(Unknown Source)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1035)
at hudson.plugins.copyartifact.BuildSelectorParameter.getSelectorFromXml(BuildSelectorParameter.java:80)
at hudson.plugins.copyartifact.ParameterizedBuildSelector.getBuild(ParameterizedBuildSelector.java:52)
at hudson.plugins.copyartifact.CopyArtifact.perform(CopyArtifact.java:280)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:772)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:160)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:535)
at hudson.model.Run.execute(Run.java:1740)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:233)
What should I do?
There's also "This assembly is parameterized -> Assembly selector for copying artifact" which I don't know if I should use it ...
Thank!
You are mixing , Build Specified and Build Specific . It is not clear what you are asking about.
For the Build Specified, you need to configure in two places:
- Under " This assembly is parameterized ", select " Build selector to copy artifact "
- The name of this parameter is what we will give later to copy the Artifact assembly.
- From a UI perspective, the user will be prompted to use the build selection interface (which allows all types of choices: latest build, specific build, newest ad, etc.).
- In the Copy Artifact step, under Which Layout , select Specified by Build Option . li>
- Another field will be displayed titled " Parameter Name " (this is by default
BUILD_SELECTOR
). - This is the Name of the Build Selector to Copy Artifact parameter that we created earlier.
- Since the default is this
BUILD_SELECTOR
, if you've called your parameterBUILD_SELECTOR
, you don't need to change anything.
The parameter value BUILD_SELECTOR
will change a lot depending on what you select on the options screen before building. You can see its possible values by printing the parameter value as a test ( echo %BUILD_SELECTOR%
on Windows, echo $BUILD_SELECTOR
on * nix) and then manually starting the build and trying different selectors.
Specifically, the value: <SpecificBuildSelector><buildNumber>123</buildNumber></SpecificBuildSelector>
will be used when the user selects Specific assembly in the options screen and enters a value123
If you need to set this parameter value outside of an assignment (from a script or a plugin with a parameterized trigger , for example ), then you will need to follow that specific structure depending on the type of selection you want.
Edit: After re-reading your question and your actual requirement (which is not the title of the question)
In your case, you don't need the Create Selector option to copy the artifact . You just need:
- Copy artifacts build step
- Enter the Project name to copy from
- Under Which Layout, select Specific Assembly
- In the Build Number section, enter
$PL_BUILD_NUMBER
(which you say is already in the assignment)