Xcode Server 4.0 git push from build trigger script



我为github上托管的项目安装了一个Xcode Bot。 我按照步骤和设置机器人使用我现有的 SSH 密钥。 验证成功,项目将签出并生成。

然后,我在预触发操作中添加了一个 shell 脚本,该脚本递增 plist 中的版本,对其进行标记,并将更改提交回 github。

但是,当我尝试从 shell 脚本进行 git 推送时,我得到这个:

--推送到 git@github.com:spex-app/spex-ios.git权限被拒绝(公钥)。

致命:无法从远程存储库读取。


为什么服务器会成功签出我的项目,但无法推送更改。 我注意到用户_xcsbuildd。 我尝试将 .ssh 密钥复制到那个/var/_xcsbuildd/.ssh 中,但这也不起作用。

我想通了。 您需要为_xcsbuildd用户创建新密钥。 然后将它们添加到 github。 此线程的底部:https://devforums.apple.com/message/1054122#1054122

sudo -u _xcsbuildd /bin/bash
ssh-keygen -t rsa -C "your_email@example.com"
ssh -T git@github.com

考虑到我在网上找到的许多其他答案(以及这个问题),我有步骤在 Xcode 6 中完成这项工作。 首先,在构建服务器上执行上述 dmclean 所述内容(进行了一些更改):

sudo -u _xcsbuildd /bin/bash
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" (when asked for a keyphrase, just hit return)
ssh -vT git@github.com (this will show you debugging output - you should not have to enter a keyphrase and it should successfully get to git)

现在,您需要在 git 帐户中设置此新公钥。 请按照以下步骤操作:(步骤 4)https://help.github.com/articles/generating-ssh-keys/

我假设您有一个适用于您的项目的构建脚本。 我们的项目有一个共享扩展和一个监视扩展。 我希望内部版本号在每个版本号上递增(并且每个内部版本号都相同)。 我们的内部版本号采用A.B.C.D(Major.Minor.Patch.build)格式。 此"运行脚本"处于主项目的"构建阶段"。 这是我们的脚本:

#!/bin/sh
# Auto Increment Version Script
# set CFBundleVersion to 1.0.0.1 first!!!
# the perl regex splits out the last part of a build number (ie: 1.1.1.1) and increments it by one
# if you have a build number that is more than 4 components, add a 'd+.' into the first part of the regex. If you have less remove one
buildPlist=${INFOPLIST_FILE}
newVersion=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$buildPlist" | /usr/bin/perl -pe 's/(d+.d+.d+.)(d+)/$1.($2+1)/eg'`
echo $newVersion;
/usr/libexec/PListBuddy -c "Set :CFBundleVersion $newVersion" "$buildPlist"
/usr/libexec/PListBuddy -c "Set :CFBundleVersion $newVersion" "$SRCROOT/${PRODUCT_NAME} Extension/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $newVersion" "$SRCROOT/${PRODUCT_NAME} WatchKit Extension/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $newVersion" "$SRCROOT/${PRODUCT_NAME} WatchKit App/Info.plist"
echo "Trying Git Config"
git config user.email "your_email@example.com"
git config user.name "XCode Build Server"
echo "Trying Git Commit"
git commit -a -m "Updated Build Numbers"
echo "Trying Git Push"
git push

如果它不起作用,请查看构建日志中的输出(在集成下)。

Some of the problems I encountered:

由于_xcsbuildd并没有真正的$HOME我不得不做 git 配置,否则我会收到 git 不知道我是谁的错误(身份错误)。 如果我在 RSA 密钥中输入一个关键字,那么它在尝试推送时会给我公钥错误(花了我一点时间才弄清楚取出关键字以使其工作)。

我希望这对某人有所帮助。

最新更新