Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Move files from bamboo working directory to Network directory in Powershell

Madhu June 11, 2024

Hi Team,

 

Can you please help me to move files from bamboo working directory to network directory in PowerShell

1 answer

2 votes
Khushboo Gupta
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 11, 2024

Hello @Madhu 

Welcome to the Atlassian Community!

To move files from a Bamboo working directory to a network directory using PowerShell, you can use the Move-Item cmdlet.

The working directory is where Bamboo temporarily places the checked-out files it's building. By default, this directory is located at <bamboo-home-dir>/local-working-dir, where <bamboo-home-dir> is the Bamboo home directory.

The checked-out files for each job are stored in a sub-directory relative to the configured working directory:

<bamboo-home-dir>/local-working-dir/<job-key>

Incase if you want to change the location of Bamboo working directory, you can refer to a KB:  https://confluence.atlassian.com/bamboo/specifying-bamboo-s-working-directory-289277246.html 

Hope it helps!

Regards,

Khushboo Gupta

Madhu June 11, 2024

Hi Khushboo Gupta,

I'm trying both Copy-Item and Move-Item but getting error. Please find the below script i'm using and error log.

 

Set Location "D:\Bamboo_New\xml-data\build-dir\PROBOTS-RPASIT-JOB1\"

pwd

Move-Item -Path .\*.log -Destination \\xxxxx.corp.choosehmc.com\Public\twf\xxxxx\Test

Copy-Item D:\Bamboo_New\xml-data\build-dir\PROBOTS-RPASIT-JOB1 -Destination \\xxxxx.corp.choosehmc.com\Public\twf\xxxxx\Test

Move-Item Error

---------------------

Path                                                
build 12-Jun-2024 00:02:01 ----                                                
build 12-Jun-2024 00:02:01 D:\Bamboo_New\xml-data\build-dir\PROBOTS-RPASIT-JOB1
error 12-Jun-2024 00:02:01 Move-Item : The user name or password is incorrect.
error 12-Jun-2024 00:02:01 At D:\Bamboo_New\temp\PROBOTS-RPASIT-JOB1-137-ScriptBuildTask-16213514140262231
error 12-Jun-2024 00:02:01 16.ps1:8 char:1
error 12-Jun-2024 00:02:01 + Move-Item -Path .\*.log -Destination \\hmcnt3.corp.choosehmc.com\Publ ...
error 12-Jun-2024 00:02:01 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error 12-Jun-2024 00:02:01     + CategoryInfo          : WriteError: (D:\Bamboo_New\x...amboo-agent.log:F 
error 12-Jun-2024 00:02:01    ileInfo) [Move-Item], IOException
error 12-Jun-2024 00:02:01     + FullyQualifiedErrorId : MoveFileInfoItemIOError,Microsoft.PowerShell.Com 
error 12-Jun-2024 00:02:01    mands.MoveItemCommand


Copy-Item Error
--------------------

Path                                                
build 12-Jun-2024 00:00:00 ----                                                
build 12-Jun-2024 00:00:00 D:\Bamboo_New\xml-data\build-dir\PROBOTS-RPASIT-JOB1
error 12-Jun-2024 00:00:00 Copy-Item : The user name or password is incorrect.
error 12-Jun-2024 00:00:00 At D:\Bamboo_New\temp\PROBOTS-RPASIT-JOB1-136-ScriptBuildTask-56319914737823582
error 12-Jun-2024 00:00:00 53.ps1:10 char:1
error 12-Jun-2024 00:00:00 + Copy-Item D:\Bamboo_New\xml-data\build-dir\PROBOTS-RPASIT-JOB1 -Desti ...
error 12-Jun-2024 00:00:00 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error 12-Jun-2024 00:00:00     + CategoryInfo          : WriteError: (\\hmcnt3.corp.c...wf\AG82090\Test:S 
error 12-Jun-2024 00:00:00    tring) [Copy-Item], IOException
error 12-Jun-2024 00:00:00     + FullyQualifiedErrorId : CreateDirectoryIOError,Microsoft.PowerShell.Comm 
error 12-Jun-2024 00:00:00    ands.CopyItemCommand
error 12-Jun-2024 00:00:00  

Can you please suggest what causing the issue.

 

Thanks in advance!!

Madhu

Khushboo Gupta
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 12, 2024

Hello @Madhu ,

The errors you're encountering, specifically "The user name or password is incorrect," suggest an issue with network authentication. When you're trying to access a network share (like \\xxxxx.corp.choosehmc.com\Public\twf\xxxxx\Test in your case), your script needs to have the correct permissions to access that location.

  • Ensure that the user account under which the Bamboo agent (or the PowerShell script) is running has the necessary permissions to access the network share.

If the direct Move-Item or Copy-Item still faces permission issues even after mapping the drive, consider using other tools or cmdlets that might handle credentials differently, such as `robocopy` for copying files, which you can call from PowerShell. Below is the example:

robocopy "D:\Bamboo_New\xml-data\build-dir\PROBOTS-RPASIT-JOB1" "\\xxxxx.corp.choosehmc.com\Public\twf\xxxxx\Test" *.log /Z /COPYALL /R:5 /W:5

 Hope it helps!

Regards,

Khushboo Gupta

Like Steffen Opel _Utoolity_ likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events