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

时间:2012-11-21 19:37:47

标签: xcode jenkins xcodebuild

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

-xcodebuild -workspace XXX -scheme NNN。

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

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

  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.

    Schemes:
        scrap

但是如果我从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.

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

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

2 个答案:

答案 0 :(得分:32)

想通了你需要做的就是设置共享方案​​。 方案>管理方案 确保选中“共享”。

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

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

答案 1 :(得分:0)

您必须忽略.gitignore文件中的 .xcodeproj / xcuserdata / .xcuserdatad。 xcodebuild -list从 .xcodeproj / xcuserdata / .xcuserdatad / xcschemes获取方案。 jenkins服务器没有这个文件所以得到没有方案,你可以在你的jenkins服务器中打开* .xcodeproj,它会创建文件,然后xcodebuild -list可以得到当前的方案。我有同样的问题,并通过上述方法解决