【问题标题】:Jenkins run a script in background詹金斯在后台运行脚本
【发布时间】:2019-09-17 16:56:15
【问题描述】:

如何使用 Jenkins 触发脚本 A(在 python 中),这样即使在 Jenkins 构建完成后,从脚本 A 内部触发的 shell 脚本也会在后台继续运行。

现在,我观察到,一旦 Jenkins 工作结束,它也会杀死后台 shell 脚本。 但是,在终端上手动运行 python 脚本很好。

有没有办法让我跳过 Jenkins 的后台 shell 脚本?

【问题讨论】:

  • 这个nohup python my_scipt.py &怎么样
  • 还有其他方法吗?我无法访问日志并且无法检查它是否在任何步骤都失败
  • 您可以将日志捕获到文件 nohup python_script.py > myprogram.out 2> myprogram.err
  • 或者更合适的方式nohup python_script.py > ${BUILD_URL}/consoleText 2> ${BUILD_URL}/consoleText
  • 但问题是 jenkins build 总会通过

标签: python shell jenkins background-process


【解决方案1】:

搜索解决方案后,我发现了这个链接“Spawning process from build”

https://wiki.jenkins.io/display/JENKINS/Spawning+processes+from+build

添加以下命令以帮助构建步骤:

BUILD_ID=dontKillMe nohup shell_script_to_run.sh &

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-12
    • 2020-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多