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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,103
Community Members
 
Community Events
184
Community Groups

Bamboo variable resolve to empty string in powershell script

I've got a powershell script within a git repository that I use to build the project.

In the script, I'm trying to run the following command

Get-ChildItem -Path ${bamboo.build.working.directory}\src -Filter project.json -Recurse | ForEach-Object { & dnu restore $_.FullName 2>1 }

and the above returns the following error

11-Feb-2016 12:39:43Get-ChildItem : Access to the path 'C:\cygwin\home\Administrator\.ssh' is denied.
11-Feb-2016 12:39:43At C:\build\FCL-FCRP-JOB1\Build\01_Build.ps1:26 char:1
11-Feb-2016 12:39:43+ Get-ChildItem -Path ${bamboo.build.working.directory}\src -Filter project.json - ...

The above script would run fine as INLINE, but the variable would resolve to empty string if it ran as a File.

Does anyone experience the same problem? Or am I missing something here?

Thank you.

2 answers

1 accepted

0 votes
Answer accepted
rverschoor
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Feb 10, 2016

Bamboo can indeed only expand variables when you use an inline script.
When you use a script file, PowerShell has absolutely no knowledge what those ${bamboo...} things are.

Passing them as arguments, or use the Bamboo environment variables, will do the trick.

It would be really useful to back up your answers with a working example.

To answer my own question, it turns out if you use powershell script inline, bamboo automatically substitute the bamboo variable into their respective values. However if you run it as a file, then you need to pass in the bamboo variable as arguments, so you need a param block inside the script file.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events