Apple CI / Xcode 服务和 Jenkins

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18059642/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:39:48  来源:igfitidea点击:

Apple CI / Xcode Service and Jenkins

iosxcodemacosjenkinscontinuous-integration

提问by fabb

Is there a way/plugin to integrate the new Xcode service and/or the new Apple CI with Jenkins?

有没有办法/插件将新的 Xcode 服务和/或新的 Apple CI 与 Jenkins 集成?

Why?

为什么?

A main issue with having a Jenkins server + an OSX build slave connected via sshis that Unit Tests do not work, as the iOS Simulator needs a graphical environment which is not present in this configuration.

通过连接 Jenkins 服务器 + OSX 构建从站的一个主要问题ssh单元测试不起作用,因为 iOS 模拟器需要此配置中不存在的图形环境。

I hope that it is possible to integrate the Xcode service (which supports Unit Testing) with Jenkins.

我希望可以将 Xcode 服务(支持单元测试)与 Jenkins 集成。

It could be that using the Apple CI will be enough for my needs, but this question aims at the integration of the Xcode service with Jenkins.

可能使用 Apple CI 就足以满足我的需求,但这个问题旨在将 Xcode 服务与 Jenkins 集成

What I do already know

我已经知道的

I have experience with the existing Xcode Jenkins plugin, but it seems not to support the brand new Xcode service or the new Apple CI. I'm especially keen on unit testing via CI (which did not work properly over a ssh session with the old way).

我有使用现有 Xcode Jenkins 插件的经验,但它似乎不支持全新的 Xcode 服务或新的 Apple CI。我特别热衷于通过 CI 进行单元测试(使用旧方式在 ssh 会话中无法正常工作)。

What I want to know

我想知道什么

I'd like info on the following issues currently not working with Jenkins and an sshconnected build slave:

我想了解有关当前不适用于 Jenkins 和ssh连接的构建从站的以下问题的信息:

  • Unit Tests on a headless system
  • Acceptance tests with Frankor similar
  • Automatic Provisioning Profile updating (Apple CI does that)
  • 在无头系统上进行单元测试
  • Frank或类似人员的验收测试
  • 自动配置文件更新(Apple CI 这样做)

And info on things that currently do work fine with Jenkins and an sshconnected build slave and still should work with an Xcode service integration:

以及目前与 Jenkins 和ssh连接的构建从站一起工作正常并且仍然应该与 Xcode 服务集成一起工作的信息:

  • Builds of different build configurations (Release, Debug, TestFlight) / schemes
  • Automatic Build number increment
    • (With Jenkins I can set the build number in my project to ${BUILD_NUMBER}, and Jenkins sets this environment variable according to its build number. When the Apple CI does the builds most probably it will set the build number instead.)
    • Handling/synchronization of Build number between Jenkins & Apple CI
  • Accessing build products of the Apple CI from different Jenkins Jobs
    • e.g. for a Job to upload to TestFlight
  • Backup of builds
  • Automatic builds on git push to a specific branch
  • E-Mail notifications
  • 不同构建配置(发布、调试、TestFlight)/方案的构建
  • 自动内部版本号增量
    • (使用 Jenkins,我可以将项目中的构建号设置为${BUILD_NUMBER},Jenkins 根据其构建号设置此环境变量。当 Apple CI 执行构建时,它很可能会设置构建号。)
    • 处理/同步 Jenkins 和 Apple CI 之间的内部版本号
  • 从不同的 Jenkins Jobs 访问 Apple CI 的构建产品
    • 例如,将作业上传到 TestFlight
  • 构建备份
  • 在 git push 上自动构建到特定分支
  • 电子邮件通知

Some additional questions/hints

一些额外的问题/提示

  • I'm not sure whether the Apple CI == Xcode serviceor if the Apple CI just usesthe Xcode service. In the latter case the Xcode service just would be like an intelligent build slave, and Jenkins maybe could use that to do builds and tests, but manage build numbers and products by itself.
  • I'm aware that the Apple CI is an separate CI, and integrating several CIs with each other is not the most easy or useful way to go. I just fear that the Apple CI is not flexible enough for my needs (see above), and that the old way with Jenkins bears some problems (see above).
  • 我不确定Apple CI == Xcode serviceApple CI是否只使用Xcode 服务。在后一种情况下,Xcode 服务就像一个智能构建奴隶,Jenkins 可能会使用它来进行构建和测试,但它自己管理构建编号和产品。
  • 我知道 Apple CI 是一个单独的 CI,并且将多个 CI 相互集成并不是最简单或最有用的方法。我只是担心 Apple CI 不够灵活,无法满足我的需求(见上文),而且 Jenkins 的旧方式存在一些问题(见上文)。

回答by Santa Claus

I believe you are going to have to choose either jenkins or xcode server, not both. I don't know much about xcode server, but I do know about jenkins and xcode 5.

我相信您将不得不选择 jenkins 或 xcode 服务器,而不是两者。我不太了解 xcode 服务器,但我知道 jenkins 和 xcode 5。

Builds with different configurations:

使用不同的配置构建

In the xcode plugin, you can set the scheme to use.

在 xcode 插件中,您可以设置要使用的方案。

Automatic Build Number Increment

自动内部版本号增量

I added a parameter to my jenkins job called XCODEBUILDNUMBER. And whenever I start a build, I simply copy the build number out of my xcode project (I increment it manually. Mine looks like 080813A) and paste it into the XCODEBUILD parameter. I use this to name my output files, etc. There are plugins for jenkins that can automatically increment your build number, but they don't integrate, or sync with xcode.

我在我的 jenkins 作业中添加了一个名为 XCODEBUILDNUMBER 的参数。每当我开始构建时,我只需从我的 xcode 项目中复制构建号(我手动增加它。我的看起来像 080813A)并将其粘贴到 XCODEBUILD 参数中。我用它来命名我的输出文件等。有 jenkins 插件可以自动增加你的内部版本号,但它们不集成,也不与 xcode 同步。

Handling/synchronization of Build number between Jenkins & Apple CI

处理/同步 Jenkins 和 Apple CI 之间的内部版本号

As I said before, I don't know of a way to sync the build numbers, but I just thought of a possible solution. You could use the command line tool plistbuddy, to set the build number in your info.plist, as a build step in your jenkins job.

正如我之前所说,我不知道同步内部版本号的方法,但我只是想到了一个可能的解决方案。您可以使用命令行工具plistbuddy在 info.plist 中设置构建号,作为 jenkins 作业中的构建步骤。

Unit Tests

单元测试

I have not successfully made unit tests work with Xcode5, but I know that the xcode plugin for jenkins supports it. I believe that the absence of the "Test After Build" key in the project settings may have something to do with it. If you make it work, i'd love to know. (I am also keen on making this work)

我还没有成功地使用 Xcode5 进行单元测试,但我知道 jenkins 的 xcode 插件支持它。我相信项目设置中缺少“Test After Build”键可能与此有关。如果你让它工作,我很想知道。(我也热衷于做这项工作)

Acceptance Tests

验收测试

From what I can tell, Frank is a command line tool. You can easily integrate it into your Jenkins job, and I believe that it will fail the build if your tests don't pass.

据我所知,Frank 是一个命令行工具。您可以轻松地将它集成到您​​的 Jenkins 工作中,我相信如果您的测试未通过,它将导致构建失败。

Accessing build products of the Apple CI from different Jenkins Jobs

从不同的 Jenkins Jobs 访问 Apple CI 的构建产品

Not completely sure what you mean, but with jenkins you can archive your build product (a .ipa), for later download and upload to a service like testflight. Again, I don't know much about Xcode Server (CI).

不完全确定您的意思,但是使用 jenkins,您可以存档您的构建产品(.ipa),以便以后下载并上传到像 testflight 这样的服务。同样,我对 Xcode Server (CI) 不太了解。

Backup of builds

构建备份

As I said before, jenkins can archive your build product. Also, I use the the ${BUILD_NUMBER} variable in my build products directory, so I have a different directory for each build. This directory is also backed up to my Time Machine, and important builds copied to my web directory.

正如我之前所说,jenkins 可以归档您的构建产品。此外,我在构建产品目录中使用了 ${BUILD_NUMBER} 变量,因此每个构建都有一个不同的目录。这个目录也备份到我的 Time Machine,重要的构建复制到我的 web 目录。

Automatic builds on git push to a specific branch

在 git push 上自动构建到特定分支

With the jenkins git plugin, you can make jenkins poll your scm in a interval specified by you, and can trigger a build on a change.

使用 jenkins git 插件,您可以让 jenkins 在您指定的时间间隔内轮询您的 scm,并且可以在更改时触发构建。

E-Mail notifications

电子邮件通知

I am sure that there is a plugin for this. (that emails you when a build failed/succeeded. in fact, this may be built-in)

我确信有一个插件可以解决这个问题。(当构建失败/成功时会向您发送电子邮件。实际上,这可能是内置的)

In Closing

在结束

The xcode CI is a full independent CI, that may be hard to integrate with jenkins. Personally, I would recommend jenkins simply due to its extendability. Sorry I don't know much about Xcode Server.

xcode CI 是一个完全独立的 CI,可能很难与 jenkins 集成。就我个人而言,我推荐 jenkins 仅仅是因为它的可扩展性。抱歉,我对 Xcode Server 了解不多。

回答by Mark

I've got unit tests running in Jenkins with Xcode 5 on my OS X build slave. Instead of using the Xcode plugin, I run as an execute shell build step:

我在我的 OS X 构建从站上使用 Xcode 5 在 Jenkins 中运行了单元测试。我没有使用 Xcode 插件,而是作为执行 shell 构建步骤运行:

xcodebuild test -scheme <scheme> -configuration Coverage -sdk iphonesimulator7.0 -destination OS=7.0,name="iPhone Retina (4-inch)"

My coverage configuration is the exact same as my Debug config, except Generate Test Coverage Reportsis set to YES, and Instrument Program Flowis set to YES. This is done so test coverage files are created. Due to a bug in Xcode 5, I call __gcov_flush();in the tearDown of all my tests. I pipe the output of this xcodebuildcommand into ocunit2junitto get test reports in Jenkins.

我的覆盖配置与我的调试配置完全相同,除了Generate Test Coverage Reports设置为YES,并且Instrument Program Flow设置为YES。这样做是为了创建测试覆盖文件。由于 Xcode 5 中的错误,我调用了__gcov_flush(); 在我所有测试的拆解中。我将此xcodebuild命令的输出通过管道传输ocunit2junit以获取 Jenkins 中的测试报告。