Invoke bamboo plan variables in a python script under script task

I have a simple script task added to my bamboo plan which is inline python script.

/usr/bin/python <<EOF
print "Hello"
EOF

It works just fine.
Now i want to just pass Hello as a plan specific variable so i configured a variable called pythontest within bamboo plan variables and provided it the value Hello.
When i switch the script to:-
/usr/bin/python <<EOF
print "$bamboo_pythontest"
EOF
It does nothing.

After going through below post:-

https://community.atlassian.com/t5/Bamboo-questions/How-I-can-access-global-and-or-plan-specific-variables-from/qaq-p/162809

/usr/bin/python <<EOF
import os
print os.environ['bamboo_pythontest]
EOF

i get error
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "/usr/lib64/python2.6/UserDict.py", line 22, in __getitem__
raise KeyError(key)
KeyError: ''

Is there a way to successfully invoke bamboo plan variables within a python inline script just like it works for a shell or batch script.

Any help here would be greatly appreciated.

Cheers,

Ashley

 

1 answer

Hi,

bamboo might be uppercase BAMBOO_pythontest, try to

print os.environ

/Poul

Hi Poul, It doesn't work. I think there must be a way to call bamboo variable from inside python based bamboo jobs, but what you are suggesting is definitely not the solution.

Suggest an answer

Log in or Join to answer
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,096 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot