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,555,469
Community Members
 
Community Events
184
Community Groups

Shell interpreter and inline bash script on Windows

We're trialling Bamboo 6.10 on a Windows 2008 server (soon to be upgraded to 2019) and I've got some shell code to perform file modifications using "sed" at the end of the build. 

The docs at https://confluence.atlassian.com/bamboo/script-289277046.html for the "Shell" option under "Interpreter" say:

This option selects the interpreter based on the first line of the script, typically using the shebang.

So I've selected "Shell" for the interpreter option, selected "Inline" for the script location option, and the full inline script I'm trying to run looks like this:

"C:/Program Files/Git/bin/bash.exe"

sed -i '/version=/c\version=${bamboo.jira.version}' gradle.properties
sed -i '/window.APP_VERSION =/c\window.APP_VERSION = ${bamboo.jira.version};' HtmlClient/src/setup.js.temp

A screenshot of the full script configuration inside the Bamboo job in case it's useful:

BambooJob.png

When i run the build plan the build just hangs forever on the first line as if it is running bash.exe and awaiting input, rather than using that bash.exe path to run the commands that follow. Using a shebang "#" in front of the bash path doesn't work either as an error is thrown due to "#" not being recognised.

The last comment by Przemek Bruski on 02/Sep/2016 4:30 PM in the issue https://jira.atlassian.com/browse/BAM-13383 suggests a second issue https://jira.atlassian.com/browse/BAM-17864 was raised to address this type of scenario. This second issue is marked as fixed so it sounds like this should be possible. 

Is what I'm trying to achieve here actually possible or do I just have to rewrite the script using cmd.exe or Powershell instead?

Any guidance is appreciated :)

 

1 answer

1 accepted

2 votes
Answer accepted
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Oct 21, 2019

Hello @Phillip Bonner

Thank you for sharing your findings, they saved me some time when investigating this.

According to my tests your inline script should start with:

#!c:\progra~1\git\bin\bash.exe

⚠️ No spaces in the path and no surrounding quotes.
This is the default format of shebang (which comes from Unix systems).


I've updated [BAM-17864] In script task, parse the shebang line and execute that interpreter directly in order to save the time of other users that might reach the same bug report.

Please let me know if that will fix the issue. =]

That did the trick thank you!

Like Daniel Santos likes this
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Oct 22, 2019

That is great! You are welcome!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events