Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-32512

Copy artifacts from project using a variable and cloudbees folder plugin

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Component/s: copyartifact-plugin
    • Labels:
      None
    • Environment:
      Jenkins 1.619
      Copy artifact plugin: 1.37
      Cloud bee's Folder Plugin: 5.1
    • Similar Issues:

      Description

      We have a deployment job that runs after some of our other build jobs, currently we have a very complicated setup where we need to add a conditional build step with the copy artifact plugin for each job that triggers the deployer. This is very suboptimal and a huge PITA to maintain. We wanted to make sure that we could dynamically trigger the the copy from the upstream project, this doesn't seem to be available (as far as I have found at least?) The next best thing was to use the parameterised build and set the name of the upstream job in a variable and then use that variable in the copy artifact plugin.

      This works fine as long as the upstream job is not in a Folder from the cloud bee's plugin. If the project is in a folder it never finds the project. I have tried specifying the project name by the same syntax as I use otherwise : Folder/Job.

      To me it seems like maybe the variables are escaped in a different way?

      Hope this can be fixed since it would make our setup much nicer.

        Attachments

          Activity

          Hide
          ikedam ikedam added a comment -

          Please attach the project configuration or report example steps to reproduce the problem.

          Show
          ikedam ikedam added a comment - Please attach the project configuration or report example steps to reproduce the problem.
          Hide
          tobiashieta tobias hieta added a comment -

          Create a job (X) that creates artifacts that is placed in a subfolder (Subfolder).
          Create a new job that is parameterised and that takes a string parameter let's call it PROJECT.
          Add a copy artifact step set the project to ${PROJECT}

          Build job X and make sure you have artifacts. Now build the copy job and put "Subfolder/X" in the PROJECT parameter.
          The copy artifact plugin will not be able to find it.
          Now put "Subfolder/X" in the project field for the copy job instead and it will work.

          Show
          tobiashieta tobias hieta added a comment - Create a job (X) that creates artifacts that is placed in a subfolder (Subfolder). Create a new job that is parameterised and that takes a string parameter let's call it PROJECT. Add a copy artifact step set the project to ${PROJECT} Build job X and make sure you have artifacts. Now build the copy job and put "Subfolder/X" in the PROJECT parameter. The copy artifact plugin will not be able to find it. Now put "Subfolder/X" in the project field for the copy job instead and it will work.
          Hide
          ikedam ikedam added a comment -

          That rather sounds like a permission issue.
          Please have a look at the following section of the Wiki page:
          https://wiki.jenkins-ci.org/display/JENKINS/Copy+Artifact+Plugin#CopyArtifactPlugin-Permissionstocopyartifact

          Show
          ikedam ikedam added a comment - That rather sounds like a permission issue. Please have a look at the following section of the Wiki page: https://wiki.jenkins-ci.org/display/JENKINS/Copy+Artifact+Plugin#CopyArtifactPlugin-Permissionstocopyartifact
          Hide
          tobiashieta tobias hieta added a comment -

          I have tried that. It actually works if I hardcode the string which makes me believe it's something else.

          Show
          tobiashieta tobias hieta added a comment - I have tried that. It actually works if I hardcode the string which makes me believe it's something else.
          Hide
          ikedam ikedam added a comment -

          Could not reproduce in my environment.
          I believe this is a permission issue.

          Report all what you tried (especially to isolate the permission issue) if you reopen this ticket.

          Tested with Jenkins 1.619 + Cloudbees Folders Plugin 5.1 + Copy Artifact 1.37.

          1. Launch the new install of Jenkins.
          2. Install CloudBees Folders Plugin.
          3. Install Copy Artifact Plugin.
          4. Create a new folder "Subfolder".
          5. Create a new freestyle project "X" in Subfolder.
            • Add "Execute shell" for Build
              • Command: export >artifact.txt
            • Add "Archive the artifacts" for Post-build Actions
              • Files to archive: artifact.txt
          6. Run Subfolder/X. It should succeed.
          7. Create a new freestyle project "copier" in the top (not in Subfolder).
            • Check "This build is parameterized"
            • Add "String Parameter" for This build is parameterized
              • Name: PROJECT
              • Default Value:
              • Description:
            • Add "Copy artifacts from another project" for Build
              • Project name: ${PROJECT}
              • Which build: Latest successful build
              • Artifacts to copy: artifact.txt
          8. Run copier with PROJECT=Subfolder/X.
          9. The build succeeds with a following log:
            Started by user anonymous
            Building in workspace C:\Users\ikedam\.jenkins\jobs\copier\workspace
            Copied 1 artifact from "Subfolder ≫ X" build number 1
            Finished: SUCCESS
            
          Show
          ikedam ikedam added a comment - Could not reproduce in my environment. I believe this is a permission issue. Report all what you tried (especially to isolate the permission issue) if you reopen this ticket. Tested with Jenkins 1.619 + Cloudbees Folders Plugin 5.1 + Copy Artifact 1.37. Launch the new install of Jenkins. Install CloudBees Folders Plugin. Install Copy Artifact Plugin. Create a new folder "Subfolder". Create a new freestyle project "X" in Subfolder. Add "Execute shell" for Build Command: export >artifact.txt Add "Archive the artifacts" for Post-build Actions Files to archive: artifact.txt Run Subfolder/X. It should succeed. Create a new freestyle project "copier" in the top (not in Subfolder). Check "This build is parameterized" Add "String Parameter" for This build is parameterized Name: PROJECT Default Value: Description: Add "Copy artifacts from another project" for Build Project name: ${PROJECT} Which build: Latest successful build Artifacts to copy: artifact.txt Run copier with PROJECT=Subfolder/X. The build succeeds with a following log: Started by user anonymous Building in workspace C:\Users\ikedam\.jenkins\jobs\copier\workspace Copied 1 artifact from "Subfolder ≫ X" build number 1 Finished: SUCCESS

            People

            • Assignee:
              ikedam ikedam
              Reporter:
              tobiashieta tobias hieta
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: