0

Im writing a batch script that calls a python script, and then calling a jenkins URL. I want to pass the jenkins some results from the python script (string results), I dont want to use the print to a tmp file and then load it to a batch vars, because in the script I sometimes print something like "File is opened, program closed. please try again!"

python gen_build_summary_info.py

set CORE = ????

set BUILD = ?????

java -jar y:\DTS_tests_run\Compiler\clean_up\jenkins-cli.jar -s http://***** build new_build_summary_report -p BUILD=%BUILD% -p CORE=%CORE%

any ideas? thanks

Atheel Massalha
  • 424
  • 1
  • 6
  • 18

1 Answers1

0
  1. You can pass the data through pipe.

In your .bat file:

python xxx.py | java -jar xxx.jar

Print the result in Python and then read it in Java. You can use something like JSON to encode multiple values together.

  1. Just get rid of the batch file and invoke your java program directly in the Python script.

One possible solution is using subprocess library to run Java, and send the result by command line arguments, like:

import subprocess
result='12345'
subprocess.call(['java', '-jar', '...(your program)', result])
  1. Use a RPC library like jsonrpc. Register a function in Java and call it in Python.
xmcp
  • 3,347
  • 2
  • 23
  • 36