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,637,843
Community Members
 
Community Events
196
Community Groups

Bamboo variables in yaml file (not bamboo specs yaml)

Hello guys! I would like to call a python script  via bamboo task (inline script) This python script load variables from yaml file like this:

parser.add_argument( '--config_path', default='config.yaml', help='path of the configuration file')

 

with open(args.config_path) as source: 
config = yaml.safe_load(source)

git_config = config['git']
git_username = git_config['username']
git_password = git_config['password']

In yaml file I would like to use  bamboo variables, how should I define bamboo variables inside yaml file?

Thanks for yout answer!

1 answer

1 accepted

1 vote
Answer accepted
Victor Debone
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Feb 20, 2020

Hello @Erik Zilinsky welcome to the community! :)

Bamboo provides variables for external scritps with environment variables. While it's possible to hack around your yaml and python scripts (see this StackOverflow answer), I would not recommend you to do that.

The best way to go would be to either read the environment variables direct into your python script, or use the inline variables that Bamboo provides with inline script tasks (documentation link).

I hope that helps!

Thanks for your answer, we want to keep using that yaml file so ... we replacing bamboo vars via chevron python package like this:

import os
import re
import sys
import chevron

template = open(sys.argv[1])

vars = {
'confluence_url': os.environ['bamboo_confluence_url'],
'nexus_user': os.environ['bamboo_nexus_user'],
'nexus_password': os.environ['bamboo_nexus_password'],
'confluence_report_page_id': os.environ['bamboo_confluence_report_page_id'],
'sonar_url' : os.environ['bamboo_sonar_url'],
'sonar_projectkey': os.environ['bamboo_sonar_projectkey'],
'sonar_secret': os.environ['bamboo_sonar_secret']
}

rendered = chevron.render(template, vars)

with open('config_composed.yaml', 'w') as composed:
print(rendered, file=composed)

Have a nice day!

Like # people like this

@Erik Zilinsky  Let me see in I Understand.  This my be way off. Your ability to translate from lone language to another and the default confuriation along with the configuration path that lets you go from not just your default yaml file to another paths or modules and the ability to add things to your configuration file is the problem? Al;ong with the other stuff you need fixed? Try to undeerstand so I can help.

I apologize if it sounds like gibberish.  I'm trying.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events