The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps section of the Pipeline Syntax page.

For a list of other such plugins, see the Pipeline Steps Reference page.

Copy Artifact Plugin

copyArtifacts: Copy artifacts from another project

  • projectName : String

    The name of the project to copy artifacts from.

    Maven projects:

    Artifacts from all modules will be copied. Enter JOBNAME/MODULENAME here to copy from a particular module; you may copy/paste this from the URL for that module when browsing Jenkins.
    Example: MyMavenJob/$MyModule

    Matrix projects:

    Artifacts from all configurations will be copied, each into a subdirectory with the name of the configuration as seen in its URL when browsing Jenkins.
    Example: If the target directory is given as fromMatrix then the copy could create $WORKSPACE/fromMatrix/label=agentA/dist/mybuild.jar and $WORKSPACE/fromMatrix/label=agentB/dist/mybuild.jar.

    To copy from a particular configuration, enter JOBNAME/AXIS=VALUE,.. as seen in the URL for that configuration.
    Example: MyMatrixJob/jdk=Java6u17

    To copy artifacts from one matrix project to another, use a parameter to select the matching configuration in the source project.
    Example: OtherMatrixJob/jdk=$jdk

    Multibranch Pipeline projects:

    Use a path consisting of the project name followed by the branch name.
    Example: /MyMultibranchProject/MyBranch

    Special letters like '/' in branch names should be escaped. You can see the exact name in "Full project name" in job pages of each branch.
    Example: ../MyMultibranchProject/feature%2Fnavigation

    See "How to reference another project by name" for more information.

  • excludes : String (optional)
    Specify paths or patterns of artifacts to exclude, even if specified in "Artifacts to copy". Can be blank.
  • filter : String (optional)
    Relative paths to artifact(s) to copy or leave blank to copy all artifacts. This works just as a filter, and doesn't care whether all specified artifacts really exists. Check the /artifact/ browser of a build to see the relative paths to use here, as the build page typically hides intermediate directories. Can use wildcards like module/dist/**/*.zip, and use comma (followed by optional whitespace) to separate multiple entries. See the @includes of Ant fileset for the exact format. May also contain references to build parameters like $PARAM.
  • fingerprintArtifacts : boolean (optional)
    Automatically fingerprint all artifacts that are copied as part of this build step.
  • flatten : boolean (optional)
    Ignore the directory structure of the artifacts in the source project and copy all matching artifacts directly into the specified target directory. By default the artifacts are copied in the same directory structure as the source project.
  • includeBuildNumberInTargetPath : boolean (optional)
    Include build number in target path. Default is false.

    When true, the build number of the source project will be included in the target path. This is particularly useful when the selector is specific and the value is a permalink, e.g. lastSuccessfulBuild.

  • optional : boolean (optional)
    Allow this build to continue even if no build is found that matches the "Which build" condition. By default this build step fails the build if no artifacts are copied.
  • parameters : String (optional)

    Jobs may be filtered to select only builds matching particular parameters or other build variables. Use PARAM=VALUE,... to list the parameter filter; this is the same syntax as described for multiconfiguration jobs in Project name except with parameters instead of axis values. For example, FOO=bar,BAZ=true examines only builds that ran with parameter FOO set to bar and the checkbox for BAZ was checked.

    You shouldn't use "Build selector for Copy Artifact" parameters here, as it doesn't preserve compatibility when you upgrade plugins, and doesn't work for builds built before upgrading.

  • resultVariableSuffix : String (optional)
    The build number of the selected build will be recorded into the variable named COPYARTIFACT_BUILD_NUMBER_(SUFFIX) for later build steps to reference. You can specify that suffix part for that variable here.

    If not specified, the source project name will be used instead (in all uppercase, and sequences of characters other than A-Z replaced by a single underscore).


    Source project name Suffix to be used
    tool1-release1.2 TOOL_RELEASE_
  • selector (optional)
    How to select the build to copy artifacts from, such as latest successful or stable build, or latest "keep forever" build. Other plugins may provide additional selections.
    The build number of the selected build will be recorded in the environment for later build steps to reference. For details, see the help of "Result variable suffix" in "Advanced" section.
      Nested Choice of Objects
    • downstream
      • upstreamProjectName : String

        Copy artifacts from a build that is a downstream of a build of the specified project. You can use variable expressions.

        Downstream builds are found using fingerprints of files. That is, a build that is triggered from a build isn't always considered downstream, but you need to fingerprint files used in builds to let Jenkins track them.

        Note: "Downstream build of" is applicable only to AbstractProject based projects (both upstream and downstream projects).

        AbstractProject based projects:
        Freestyle projects
        Multi-configuration projects
        Maven projects
        Non AbstractProject based projects:
        Pipeline jobs (aka. Workflow jobs)

      • upstreamBuildNumber : String
        The number of the build to find its downstream build. You can also specify display names. You can use variable expressions.
    • lastWithArtifacts
      • lastCompleted
        • $class: 'MultiJobBuildSelector'
          • buildParameter
            • parameterName : String
              Name of the "build selector" parameter. A parameter with this name should be added in the build parameters section above. There is a special parameter type for choosing the build selector.

              You can pass not only the parameter name, but also the parameter value itself. This is useful especially used with workflow-plugin.

          • permalink
            • id : String
          • $class: 'PromotedBuildSelector'
            • level : int
          • latestSavedBuild
            • specific
              • buildNumber : String
                While this selector is for build numbers (e.g. "22" for build #22), you can also resolve build parameters or environment variables (e.g. "${PARAM}"). The display name of a build and permalinks (e.g. "lastSuccessfulBuild", "lastBuild"...) can be used as well.
            • lastSuccessful
              • stable : boolean (optional)
            • upstream
              • allowUpstreamDependencies : boolean (optional)
              • fallbackToLastSuccessful : boolean (optional)
              • upstreamFilterStrategy (optional)
                Jenkins launches only one build when multiple upstreams triggered the same project at the same time. This field specifies from which upstream build to copy artifacts in those cases. "Use the oldest" copies artifacts from the upstream build with the smallest build number (that is, oldest). "Use the newest" copies artifacts from the upstream build with the largest build number (that is, newest). The default value is "Use global setting", which behaves as configured in "Manage Jenkins" > "Configure System".
                • Values: UseGlobalSetting, UseOldest, UseNewest
            • workspace
            • target : String (optional)
              Target base directory for copy, or leave blank to use the workspace. Directory (and parent directories, if any) will be created if needed. May contain references to build parameters like $PARAM.

            Was this page helpful?

            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.