首页 > 解决方案 > Jenkins 构建失败并出现 OSError:[Errno 2] 没有这样的文件或目录

问题描述

我有一个执行 rsync 命令的构建脚本。

 rsync_cmd = [
        'rsync', '-rcv',
        src_dir,
        dest_dir]
print "Running {}".format(' '.join(rsync_cmd))
rsync_proc = subprocess.Popen(rsync_cmd)
    try:
        rsync_proc.wait()
    except KeyboardInterrupt:
        rsync_proc.terminate()
        rsync_proc.wait()
        raise

当我在构建服务器上运行命令行时,它运行良好。但是当同样通过 Jenkins 运行时,我得到以下错误

  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

这是几天前运行的。我没有改变任何东西。运行构建的服务器使用的是 Ubuntu 16.04,我最近对其进行了软件包更新。这是我唯一能想到的。但不确定是否相关。我正在使用的python版本是

python:
  Installed: 2.7.12-1~16.04
  Candidate: 2.7.12-1~16.04

标签: python-2.7jenkins

解决方案


推荐阅读