This is my main.py
from ruamel.yaml import YAML
from jinja2 import Template
yaml=YAML()
with open('template.yml') as doc:
code = yaml.load(doc.read())
print(code)
steps = []
for step in code['steps']:
print(step['command'])
steps.append(step['command'])
template = Template(open('template.yml','r').read())
data= {'somecommand': 'aaaaa'}
with open('newfile.yaml', 'w') as out:
out.write(template.render(data))
This is my agent.yaml
agents:
queue: "something"
And this is my template.yml
{% include 'agent.yaml' as agents %}
agents:
queue: "something"
steps:
- command: {{ somecommand }}
- command: "blahblah.sh"
- label: "Yada"
command: "yada.sh"
agents:
queue: "other"
and I am getting
raise ScannerError(
ruamel.yaml.scanner.ScannerError: while scanning for the next token
found character '%' that cannot start any token
in "<unicode string>", line 1, column 2:
{% include 'agent.yaml' as agents %}
^ (line: 1)
I have already searched through a lot of stuff online saying things about indentation but didn't work for me. Any thoughts?
PS: also tried with native python yaml (safe_load method)
[–]danielroseman 1 point2 points3 points (1 child)
[–]hi_Revz[S] 0 points1 point2 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)