从命令行运行时,xcodebuild命令提供的结果与从Jenkins运行时的结果不同

Gru*_*kes 21 xcode xcodebuild jenkins

我正在使用Jenkins建立CI系统并且发现构建失败了因为xcodebuild报告我执行该行时没有方案

-xcodebuild -workspace XXX -scheme NNN.

我无法弄清楚为什么会发生这种情况,所以为了消除我的工作空间搞砸的东西,我使用XCode创建了一个新的项目模板,发现我对任何xcodebuild命令和任何工作空间/项目的行为都有所不同.

模板项目称为scrap,如果从终端命令行运行此命令,例如:

  xcodebuild -list
Run Code Online (Sandbox Code Playgroud)

它输出

Information about project "scrap":
    Targets:
        scrap

    Build Configurations:
        Debug
        Release

    If no build configuration is specified and -scheme is not passed then "Release" is used.

    Schemes:
        scrap
Run Code Online (Sandbox Code Playgroud)

但是如果我从Jenkins中运行xcodebuild -list,那么输出就是:

Building in workspace /Users/Shared/Jenkins/Home/workspace/scrap
[scrap] $ /bin/sh -xe /var/folders/ph/s6dvlfq9769741g_yzmjlmz000007c/T/hudson3765407964219991487.sh
+ xcodebuild -list
Information about project "scrap":
    Targets:
        scrap

    Build Configurations:
        Debug
        Release

    If no build configuration is specified and -scheme is not passed then "Release" is used.

    This project contains no schemes.
Run Code Online (Sandbox Code Playgroud)

这是最简单的jenkins工作 - 我所做的就是创建一个新工作,将其设置为自由式软件项目,然后添加一个Execut shell的构建步骤并添加xcodebuild -list命令,就是这样.

为什么xcodebuild说有没有方案?为什么在Jenkins内部运行时表现不同?

pox*_*ion 32

想通了你需要做的就是设置要共享的方案.Scheme> Manage Schemes确保选中"Shared".

这将生成一个新的文件夹/文件.../xcshareddata/xcschemes/???.xcscheme

将此文件检入您的源代码管理中,方案现在应该出现在您的jenkins框中.