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

How do you preserve path slashes stored in a inject variable?

Steve Messer
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 20, 2023

When I save a path to the inject variable (save it to the associated file) and then retrieve it, all the the slashes have been stripped.

 

How do you preserve the slashes when retrieving the injected path?

 


SciptZipPath: C:\agent\xml-data\build-dir\UT-RPER348-OB1\DBScripts_2023.16.23680.25.zip

when read back in:

C:agent xml-data build-dir UT-RPER348-JOB1DBScripts_2023.16.23680.25.zip

Here is how I am saving the variable in a script task:

$scriptZipPath = Join-Path -Path $bambooWorkingDirectory -ChildPath $archiveName;

$scriptInjectPath = "${bamboo.build.working.directory}\bamboo\archive.properties";
$propertiesFile = New-Item -Path $scriptInjectPath -ItemType "file" -Force;
Add-Content $propertiesFile "zipPath=$scriptZipPath";

Testing reading back in as follows:

 

Write-Host ${bamboo.inject.zipPath};

 

 

1 answer

1 accepted

2 votes
Answer accepted
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 20, 2023

Hello @Steve Messer

When exporting the path, make sure to use double backslashes (\\). Bamboo is written in Java and all parsing depends on such language, which will consider two slashes as a single "\" character. If you specify just on backslash, it will be treated as a whitespace or linebreak.

In your case:

SciptZipPath: C:\\agent\\xml-data\\build-dir\\UT-RPER348-OB1\\DBScripts_2023.16.23680.25.zip

Kind regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Steve Messer August 22, 2023

Yes, that was the issue, thanks

Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 22, 2023

Thanks, @Steve Messer make sure to hit the Accept button so this answer can help others.

Cheers,

Eduardo Alvarenga
Atlassian Support APAC

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events