【问题标题】:Command prompt gives different output than git bash命令提示符提供与 git bash 不同的输出
【发布时间】:2013-12-05 00:39:53
【问题描述】:

所以我想在 Jenkins 中执行一个批处理脚本:

for /f %%i in ('git rev-list --count %BRANCH_NAME% ^^%MERGE_TO%') do set commits=%%i

其中 %BRANCH_NAME% 和 %MERGE_TO% 被传递给 Jenkins 作业。执行时,输出如下:

C:\Program Files (x86)\Jenkins\jobs\Merge\workspace>for /F %i in ('git rev-list --count branch ^mrgbld') do set commits=%i 

C:\Program Files (x86)\Jenkins\jobs\Merge\workspace>set commits=2305

该命令应该返回 5,而不是 2305。事实证明,如果你在 git bash 中运行该命令,你会得到 5,但在 windows 命令提示符(Jenkins 执行命令的地方)运行它会得到 2305。

我正在寻找一种方法来欺骗 Jenkins 在 git bash 中运行命令,或者让 windows 命令提示符提供相同的输出。有什么想法吗?

【问题讨论】:

    标签: git bash batch-file jenkins cmd


    【解决方案1】:

    使用不同形式的 git 命令解决了这个问题:

    git rev-list --count %MERGE_TO%..%BRANCH_NAME%
    

    这将返回正确数量的提交,无论是在 git 还是 windows 命令中运行

    【讨论】:

      猜你喜欢
      • 2015-06-18
      • 2019-01-03
      • 1970-01-01
      • 2011-07-14
      • 1970-01-01
      • 2017-05-25
      • 2021-08-20
      • 2013-03-30
      • 2020-07-06
      相关资源
      最近更新 更多