Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Xcode Server 4.0 git从构建触发器脚本推送_Ios_Xcode_Ssh Keys_Osx Server_Xcode Server - Fatal编程技术网

Ios Xcode Server 4.0 git从构建触发器脚本推送

Ios Xcode Server 4.0 git从构建触发器脚本推送,ios,xcode,ssh-keys,osx-server,xcode-server,Ios,Xcode,Ssh Keys,Osx Server,Xcode Server,我为一个托管在github上的项目安装了一个Xcode Bot。我按照步骤设置bot以使用我现有的SSH密钥。验证成功,项目将签出并构建 然后,我在pre-trigger操作中添加了一个shell脚本,它在plist中增加版本,标记它,并将更改提交回github 但是,当我尝试从shell脚本执行git推送时,我得到以下结果: -- 推动git@github.com:spex app/spex-ios.git 权限被拒绝(公钥) 致命:无法从远程存储库读取 为什么服务器会成功签出我的项目,但无

我为一个托管在github上的项目安装了一个Xcode Bot。我按照步骤设置bot以使用我现有的SSH密钥。验证成功,项目将签出并构建

然后,我在pre-trigger操作中添加了一个shell脚本,它在plist中增加版本,标记它,并将更改提交回github

但是,当我尝试从shell脚本执行git推送时,我得到以下结果:

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

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



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

我明白了。您需要为xcsbuildd用户创建新密钥。然后将它们添加到github。此线程的底部:


考虑到我在网络上找到的许多其他答案(以及关于这个问题),我有在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)

我假设您有一个项目的构建脚本。我们的项目有一个共享扩展和一个手表扩展。我希望构建数量在每个节点上递增(并且在每个节点上相同)。我们的版本号采用A.B.C.D格式(主要版本、次要版本、补丁版本、版本)。此“运行脚本”处于主项目的“构建阶段”。以下是我们的脚本:

#!/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
如果不起作用,请查看构建日志中的输出(在集成下)

因为xcsbuildd实际上没有$HOME,所以我必须进行git配置,否则我会遇到git不知道我是谁的错误(身份错误)。如果我在RSA密钥中放入一个密钥短语,那么在尝试推送时它会给我公钥错误(我花了一点时间才弄清楚如何取出密钥短语使其工作)


我希望这对其他人有所帮助。

请分享您用于增量构建编号并推送到git的脚本好吗?
#/bin/s#提交的版本计数为次要版本(例如1.0.0)buildNumber=$(git rev list HEAD | wc-l | tr-d'')echo“buildNumber:$buildNumber”/usr/libexec/PlistBuddy-c”Set:CFBundleVersion$buildNumber“MyProject/MyProject.plist”git标记-a“$buildNumber”-m“$buildNumber”git push--tags
上面的脚本只是用repo中的rev commit来标记次要版本。我也遇到了问题,如果手动转到构建服务器中的目录,可以尝试所有命令。我还必须在配置文件中配置push.default行为,我使用“git config--global push.default simple”全局设置配置文件在服务器的命令行上,或者您可以在脚本中不使用--global选项也必须使用相同的Xcode服务器bot用户克隆我的repo,并使用ssh密钥创建一个新bot,以便它使用这些特定凭据。
#!/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: