I am trying to use Popen to run a java program that takes a few arguments, the last of them is a xml template.
What I have so far attempts to pass the value of the template through communicate(), but it doesn't seem to work.
command = [
'java',
'-jar',
'~/jenkins-cli.jar',
'-noKeyAuth',
'-s',
'docker-host',
'create-job',
(self.project.project_name+'-'+env)
]
subprocess.Popen(command,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
).communicate(input=template.render(template_vars))
I know for a fact that the value of template.render(template_vars) is correct, I can use the output from that function call on the command line and it works perfectly, the issue is only in passing the value to the process.
If I run the following from the command line everything works.
java -jar ~/jenkins-cli.jar -noKeyAuth -s jenkins-host create-job test-dev < template.xml
Is there a better way to send the output of template.render(template_vars) as input to the process?