copyArtifacts projectName: 'myproject'
In many places throughout Jenkins, you can refer to another project/job by name. For example, in a Pipeline Script, you might want to copy artifacts from another project:
copyArtifacts projectName: 'myproject'
That’s all you need to do if your target project’s name is simply alphanumeric, and is a simple project without subprojects, and has a unique name throughout your entire Jenkins controller. Read on for more complex scenarios…
If you’re using the Folders Plugin and you have multiple projects with the same name that are in different folders, you can differentiate between them using a path, similar to a Unix filesystem path. There are two types of paths:
Absolute paths begin with a forward slash, and refer to a project by describing the complete path to navigate to the project from the home page of your Jenkins controller. For example, to reference a project in the root of your Jenkins controller:
/myproject
Or, to reference a project in a subfolder:
/myfolder/myproject
Relative paths begin with something other than a forward slash, and refer to another project in relation to the current project. For example, say you have projects with the following absolute paths:
/thatproject /folder/someproject /folder/subfolder/myproject /folder/subfolder/anotherproject
In a Pipeline Script for /folder/subfolder/myproject
, you could refer to /folder/subfolder/anotherproject
using this relative path:
anotherproject
And you could refer to /folder/someproject
using this relative path, where ..
means to look in the parent folder:
../someproject
And you could refer to /thatproject
using this relative path:
../../thatproject
Some types of projects — such as Maven projects, Matrix projects, and Multibranch projects — have subcomponents. You can refer to these subcomponents as follows:
You can refer to an entire Maven project:
mymavenproject
Or to a group within a Maven project:
mymavenproject/my.group
Or to a particular module:
mymavenproject/my.group$MyModule
Special characters in paths should be URL-encoded. For example, if your Multibranch Pipeline has a branch with a slash in it (feature/myfeature
), replace the slash with %2F
:
mymultibranchproject/feature%2Fmyfeature
See the Jenkins::getItem()
function.
Please submit your feedback about this page through this quick form.
Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?
See existing feedback here.