首页 文章

注册来自协作的消息,如XCSBuildService,以接收Xcode Bots集成号

提问于
浏览
3

在Xcode Bots构建期间,每次运行都会分配 integration number . 此编号不会显示在构建日志中,但可以方便地将http链接创建回CI环境或企业应用商店中构建的各个Xcode Bots .

/Library/Server/Xcode/Logs/xcsbuildd.log 中,我发现 XCSBuildServicecollabd 获取一条消息/事件,其结构包含集成号 .

Is there a way to register to the same event in an own (OSX) program and receive this message/event?


到目前为止,我发现获得Xcode Bots集成号的唯一丑陋方法是解析xcsbuildd.log文件,但缺点是我真的想要这样做!)?

例:

sudo grep -r "integration =" /Library/Server/Xcode/Logs/xcsbuildd.log | tail -1 | cut -d'=' -f 2| cut -d';' -f 1 |tr -d '\040\011\012\015'

给我一个从空白处剥离的最新集成号...

Edit: 刚刚发现,如果您在方案中实际包含以下脚本作为Build-post-action,它将创建一个文件(例如/ Library / Server / Xcode / Data / BotRuns / Cache / 22016b1e-2f91-4757-b3b8-322233e87587 /source/integration_number.txt)具有集成号而不需要sudo . Xcode Bots似乎序列化了不同的构建,因此它们不是并行执行的,因此可以使用文件中创建的集成号 .

grep -r "integration =" /Library/Server/Xcode/Logs/xcsbuildd.log | tail -1 | cut -d'=' -f 2| cut -d';' -f 1 |tr -d '\040\011\012\015' >  ${PROJECT_DIR}/integration_number.txt

1 回答

  • 0

    特别是获取集成内部版本号的情况,我添加了一个简单的答案here .

    重复自己(并保持这不被拒绝投票为1行答案):


    我在 Xcode 项目中使用 Shell Script Build Phase 实现了这个 . 就我而言,我使用集成号来设置我构建产品的内部版本 . 我的脚本看起来像这样:

    if [ "the$XCS_INTEGRATION_NUMBER" == "the" ]; then
        echo "Not an integration build…"
        xcrun agvtool new-version "10.13"
    else
        echo "Setting integration build number: $XCS_INTEGRATION_NUMBER"
        xcrun agvtool new-version "$XCS_INTEGRATION_NUMBER"
    fi
    

    请注意, XCS_INTEGRATION_NUMBER 默认存在于 Xcode Server 构建环境中 . 如果要模拟集成构建(出于此脚本的目的),您只需将其作为自定义变量添加到构建设置中 .

相关问题