6

I have configured the VSTS agent on my MacBook Pro and it works perfectly when I manually run it (using ./run.sh).

However when I configure the VSTS agent to run as a service (using ./svc.sh install and ./svc.sh start) and queue a new build in VSTS I receive an error (on the signing step) "ANDROID_HOME not set".

I have the following configured in my .bash_profile:

export ANDROID_HOME=/Users/$(whoami)/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

The path is correct and also running echo $ANDROID_HOME returns the expected value (in this case /Users/mvanbeusekom/Library/Android/sdk).

Does anybody know what could be wrong?

4

1 回答 1

21

在您的代理文件夹中,有一个名为 runsvc.sh 的文件。在那里添加您的出口。您将看到一条注释掉的行,提示您将环境设置放在哪里:

# insert anything to setup env when running as a service
export ANDROID_HOME=/Users/$(whoami)/Library/Android/sdk

确保重新启动服务。

原因.bash_profile对您不起作用是因为该服务在运行时无权访问它。

我遇到了同样的问题并在这里找到了解决方案:https ://github.com/Microsoft/vsts-tasks/issues/1726#issuecomment-219725321

对于那些使用 Xamarin 开发的人,您通常需要这个:

# insert anything to setup env when running as a service
export ANDROID_HOME=/Users/$(whoami)/Library/Developer/Xamarin/android-sdk-macosx
于 2016-06-20T06:30:45.763 回答