小编Abh*_*hek的帖子

Jenkins 执行 shell 的行为不同

我正在创建一个 Jenkins 项目,它在构建时执行 shell。在执行 shell 中,我正在运行一个 python 脚本,例如 `python3 pythonScriptFile.py "${arg1}" "${arg2}" "${arg3}"

python文件内部调用shell脚本。

python -> shell1 -> shell2 -> 返回python文件继续执行。

当我在终端中使用参数执行 python 文件时,执行是一个接一个同步的。

但是当我在 Jenkins 中运行相同的命令时,首先执行 shell,然后执行 python 文件。

`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")`
Run Code Online (Sandbox Code Playgroud)

输出:

Script executed (which is a echo inside shell)
SCRIPT Started
SCRIPT COMPLETED`
Run Code Online (Sandbox Code Playgroud)

预期输出:

SCRIPT Started
Script executed (which is a echo inside shell)
SCRIPT COMPLETED`
Run Code Online (Sandbox Code Playgroud)

python shell jenkins

1
推荐指数
1
解决办法
317
查看次数

标签 统计

jenkins ×1

python ×1

shell ×1