【问题标题】:Trying to run a shell command in Rakefile尝试在 Rakefile 中运行 shell 命令
【发布时间】:2014-10-23 07:31:28
【问题描述】:

我正在尝试在我的 RakeFile 中运行以下 shell 命令

exclusions = args.version >= "7" ? " -t ~@failing-scenario"  : ""
current_date = DateTime.now.to_s
t.cucumber_opts = "-r Frank/features " + args.selection + (args.idiom == "ipad" ? " -t ~@iphone" : " -t ~@ipad") + exclusions  + " --out ci_artifacts/frank_results"+current_date+".txt --format pretty --format html --out ci_artifacts/frank_results.html --format junit --out ci_artifacts"
sh 'tail -n 3 ci_artifacts/frank_results" + current_date + ".txt >> frank_runtimes.txt'

当我在sh 中运行shell 命令时,我尝试访问的文件不再存在,但如果我尝试在cucumber_opts 中运行该命令,它无法识别tail 命令并且需要一个目录。

基本上我要做的是保存 Frank 的所有输出,然后获取实际输出时间并将它们保存在不同的文件夹中。

【问题讨论】:

    标签: ruby shell cucumber rake


    【解决方案1】:

    $PATH$PWD 在从其他程序运行 shell 命令时可能不是您所期望的。解决此问题的最佳方法是为您引用的每个文件指定完整路径,无论是字面意思(以下示例)还是使用变量来引用脚本所在的目录或用户的主目录等内容。

    sh '/usr/bin/tail -n 3 /path/to/ci_artifacts/frank_results" + current_date + ".txt >> /path/to/frank_runtimes.txt'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-26
      • 1970-01-01
      • 1970-01-01
      • 2012-04-05
      • 1970-01-01
      • 2015-08-03
      • 2014-06-26
      • 1970-01-01
      相关资源
      最近更新 更多