Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-18444

SCP of artifact with nested subdirectory results in the location folder also being created at the remote

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Low Low
    • 9.1.0
    • 5.14.5
    • SCP and SSH tasks
    • None

      Summary

      When SCPing an artifact of multiple nested directories + files and the location of the artifact is not defined as the root of the working directory; the location directory is also created at the destination, when instead we just want the contents of the location to be copied (not the location directory itself).

      It's easier to articulate with the example below.

      Steps to Reproduce

      1. Source directory:
        + dir working_directory
        |  + dir build
        |    + file index.html
        |    + dir css
        |      + file style.css
        
      2. Artifact definition:
        * Location: build
        * Copy pattern: **
      3. SCP Task to copy Artifact to a remote path: /var/www/public_html (ensure this path exists on the remote or we will hit BAM-14439 which will change the result)

      Expected Results

      The remote should end up with: /var/www/public_html/index.html

      Actual Results

      The remote ends up with /var/www/public_html/build/index.html

      Notes

      • This behavior is completely different (and aligns with what's expected) if in the above example, the css subdirectory and style.css do not exist.
      • The difference in the above scenario, seems to be the recursive copy. It's like performing:
        • scp -r build user@host:/var/www/public_html instead of performing:
        • scp -r build/* user@host:/var/www/public_html
      • The Artifact Download task downloads the same artifact as expected, without creating the build directory.
      • If the target directory (e.g. public_html) doesn't exist, the build folder isn't created (BAM-14439)
      • If the same artifact is downloaded in a separate stage into the root of the working directory, SCP copies it as expected.

      Workaround

      • Create a separate stage in the plan which has:
        • Artifact Download task: This will download the artifact we were previously SCPing, to the root of the working directory of the new stage. You'll need to make sure the definition of the previous artifact is shared so it can be retrieved in another stage.
        • SCP task that references the Artifact downloaded and copies it to the remote location.

      or

      • Use a script task to SCP the files like this example:
        sshpass -p ${bamboo.scp_password} scp -r build/* user@host:/var/www/public_html
        

            [BAM-18444] SCP of artifact with nested subdirectory results in the location folder also being created at the remote

            Jakub Cabaj (Inactive) made changes -
            Fix Version/s New: 9.1.0 [ 102591 ]
            Jakub Cabaj (Inactive) made changes -
            Resolution New: Fixed [ 1 ]
            Status Original: Gathering Impact [ 12072 ] New: Closed [ 6 ]
            SET Analytics Bot made changes -
            Support reference count Original: 3 New: 4
            Jakub Cabaj (Inactive) made changes -
            Remote Link New: This issue links to "Page (Confluence)" [ 819658 ]
            Pawel Skierczynski made changes -
            Status Original: Needs Triage [ 10030 ] New: Gathering Impact [ 12072 ]
            Monique Khairuliana (Inactive) made changes -
            Workflow Original: Bamboo Workflow 2016 v1 - Restricted [ 2306615 ] New: JAC Bug Workflow v3 [ 3384978 ]
            Status Original: Open [ 1 ] New: Needs Triage [ 10030 ]
            Owen made changes -
            Symptom Severity Original: Minor [ 14432 ] New: Severity 3 - Minor [ 15832 ]
            SET Analytics Bot made changes -
            Support reference count Original: 2 New: 3
            SET Analytics Bot made changes -
            Support reference count New: 2
            Krystian Brazulewicz made changes -
            Occurrence Factor New: 25% [ 12831 ]
            Status Original: Needs Triage [ 10030 ] New: Open [ 1 ]

              Unassigned Unassigned
              jowen@atlassian.com Jeremy Owen
              Affected customers:
              3 This affects my team
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: