在Xcode Bots触发器中安装Pod [英] Pod Install in Xcode Bots Trigger

查看:202
本文介绍了在Xcode Bots触发器中安装Pod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过以下内容启动了预集成触发器

I started the pre integration trigger with the following

cd "${XCS_PRIMARY_REPO_DIR}"
pwd
pod install --verbose

它给了我

pod: command not found

简单吧?找不到pod二进制文件,因此,我将其指向路径.容易.

Simple right? Can't find the pod binary so, I'll just point it over to the path. Easy.

cd "${XCS_PRIMARY_REPO_DIR}"
pwd
/usr/local/bin/pod install --verbose

哪位给我以下内容

env: ruby_executable_hooks: No such file or directory

这使我认为未正确设置红宝石来运行触发器.现在,了解构建服务器终端中的一个简单的"pod安装"即可解决所有这些问题,并且运行正常且繁琐.该项目肯定可以在构建服务器上正确构建.

This makes me think ruby isn't set up right to run for the triggers. Now understand a simple "pod install" in the terminal of the build server fixes all this and runs fine and dandy. The project definitely builds properly on the build server.

因此,由于我认为环境混乱,因此我将尝试从wrapper目录运行该环境,这应该设置得很好.这就是它的目的对吗?从历史上讲,每当我需要ruby在构建的运行脚本阶段运行时,此方法就起作用.因此,我们继续进行触发.

So since I think the environment is messed up, I'll try to run it from the wrapper directory, that should set up good and nice. That's what it's made for right? This worked historically whenever I needed ruby to run in a run script phase of the build. So here we go on the trigger.

~/.rvm/wrappers/ruby-2.2.3@global/pod install

我在构建服务器的终端中对此进行了测试,它很酷,因此将其放入触发器中,我得到了

I test this one in the terminal of the build server and it's cool with it, so I put it into the trigger and I get this

/Users/XcodeServer/.rvm/wrappers/ruby-2.2.3@global/pod: line 7: exec: pod: not found

:/好吧,我整理了pod的源代码,然后看它在第7行显示了什么内容

:/ Alright I crack up the pod source and see what it says on line 7

exec pod "$@"

我不是一个红宝石的人,但这对我没有任何意义.哦,是的,我尝试将cocoapods直接下载到usr/local/bin中,而不是先将其卸载到其他目录中,方法是先卸载所有cocoapods,然后执行以下操作

I'm not a ruby person but it didn't mean anything to me. Oh yeah and I tried downloading cocoapods directly into usr/local/bin, rather than letting it install into some other directory, by first uninstalling all cocoapods and then by doing the following

sudo gem install -n /usr/local/bin cocoapods --pre

我放--pre是因为我需要1.1.0.rc.2来修复构建swift 3的错误.任何人,这都不起作用.似乎其他所有人都可以简单地将

I put --pre because I needed 1.1.0.rc.2 to fix a bug with building swift 3. Any who, it all doesn't work. It seems like everyone else can simply put

cd /path/to/proj/
pod install

进入他们的Xcode bot触发器,并使其工作.

into their Xcode bot triggers and have them work.

推荐答案

我让触发器在进行Pod安装的构建服务器上运行脚本.

I had the trigger run a script on the build server that did the pod install.

因此,在构建服务器上制作具有以下内容的shell脚本:

So make a shell script on your build server that has the following:

#make sure the encoding is correct
export LANG=en_US.UTF-8

# fix the path so Ruby can find it's binaries
export PATH=/usr/local/bin:$PATH
echo "PATH: $PATH"

# update or install depending on what we got
if [ -d ${PODS_DIR} ]; then 
    # pods directory exist
    echo "=================="
    echo "   Delete Pods"
    echo "=================="

    # delete cocoapods files if they exist
    rm -rf "${PODS_DIR}"
    eval rm "${BS_SRCROOT}/Podfile.lock"
    eval rm -rf "${BS_SRCROOT}/${BS_EXECUTABLE_NAME}.workspace"
    echo "Deleted Pods directory ${PODS_DIR}"
    echo "Deleted ${BS_EXECUTABLE_NAME}.workspace"
    echo "Deleted Podfile.lock"
else 
    # no need to delete pod files
    echo "Pods NOT detected at ${PODS_DIR}"
fi

echo "=================="
echo "   Install Pods"
echo "=================="

# make sure we are where we need to be
eval cd "${BS_SRCROOT}"
pwd
~/.rvm/wrappers/ruby-2.2.3@global/pod install

在命名脚本时,请记住使用"sh"后缀.然后在您的漫游器触发器中像这样运行脚本

Remember to use the 'sh' suffix when naming the script. And then in your bot trigger run the script like this

sh ~/Path/to/Scripts/podUpdateHack.sh

有点傻,但是它能起作用,\\(())_/\哦,是的,所有这些愚蠢的评估都存在,因为BS_SRCROOT是XCode机器人上的环境变量,它引用了环境变量$ XCS_PRIMARY_REPO_DIR.您可以将其替换为$ XCS_PRIMARY_REPO_DIR并删除评估.我不记得是谁定义了可能来自工作区的PODS_DIR,而BS_EXECUTABLE_NAME是项目中可执行文件名的重新定义,因为此时它不存在.

Kind of silly but it works, ¯\_(ツ)_/¯ Oh yeah all those dumb evals are there because the BS_SRCROOT is an environment variable on XCode bots, which references the environment variable $XCS_PRIMARY_REPO_DIR. You can just replace it with $XCS_PRIMARY_REPO_DIR and remove the eval. I don't remember who defines PODS_DIR that might be from the workspace and BS_EXECUTABLE_NAME is a redefinition of the executable name from the project since it doesn't exist at this point in time.

希望能帮助亲戚.

这篇关于在Xcode Bots触发器中安装Pod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆