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

    XMLWordPrintable

Details

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

    Description

      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
        

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jowen@atlassian.com Jeremy Owen
              Votes:
              3 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: