0

Jenkins Execute shell behaving differently

sesame technologies 1 year ago 0

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`