Reputation: 39
I am creating a Jenkins project which executes a shell on build. Inside the execute shell I am running a python script like `python3 pythonScriptFile.py "${arg1}" "${arg2}" "${arg3}"
the python file internal call a shell script.
python -> shell1 -> shell2 -> return back to python file to continue execution.
when i execute the python file with arguments in terminal the the execution is synchronous one after the other.
but when I run the same in Jenkins first the shell is executed then the python file.
`print("SCRIPT Started")
process = os.system("""sh script.sh -t {arg1} -e {arg2}""")
process.wait()
if process.returncode != 0:
sys.exit()
print("Error executing build script")
print("SCRIPT COMPLETED")`
Output:
Script executed (which is a echo inside shell)
SCRIPT Started
SCRIPT COMPLETED`
Expected Output:
SCRIPT Started
Script executed (which is a echo inside shell)
SCRIPT COMPLETED`
Upvotes: 1
Views: 384
Reputation: 141030
[ Why does that happen ? ]
The buffering of a standard output stream depends on the environment and program settings.
In Jenking the output stream of python program is fully buffered, while interactive program connected to a terminal is line buffered.
[ How to fix it ? ]
Upvotes: 5