简体   繁体   English

如何使用Jenkins前端从git调试android项目?

[英]How to debug android project from git using Jenkins frontend?

I have installed Jenkins on my ubuntu 11.04 system using command "apt-get install jenkins". 我使用命令“apt-get install jenkins”在我的ubuntu 11.04系统上安装了Jenkins。 I am able to executes "ant debug" command from linux command line well and completed successfully But when i am trying to debug Android project from git hub using jenkins frontend by setting build target "Invoke ant" with properties "sdk.dir=/opt/android-sdk-linux-ics". 我能够很好地从linux命令行执行“ant debug”命令并​​成功完成但是当我尝试使用jenkins前端通过设置构建目标“调用ant”来调试Android项目时使用属性“sdk.dir = / opt / Android的SDK-Linux的芯片”。 It is giving following error Console Output : 它给出了以下错误控制台输出:

########################################################################################

Started by user anonymous
Building in workspace /var/lib/jenkins/workspace/touchanimtn
Checkout:touchanimtn / /var/lib/jenkins/workspace/touchanimtn - hudson.remoting.LocalChannel@72cd429b
Using strategy: Default
Last Built Revision: Revision 3e4b580644fad8b059fb5c13925d3d86fa402187 (origin/HEAD, origin/master)
Fetching changes from 1 remote Git repository
Fetching upstream changes from https://github.com/ssamar/touchanimtn.git
Seen branch in repository origin/HEAD
Seen branch in repository origin/master
Commencing build of Revision 3e4b580644fad8b059fb5c13925d3d86fa402187 (origin/HEAD, origin/master)
Checking out Revision 3e4b580644fad8b059fb5c13925d3d86fa402187 (origin/HEAD, origin/master)
Warning : There are multiple branch changesets here
[touchanimtn] $ ant -Dsdk.dir=/opt/android-sdk-linux-ics clean debug
Buildfile: /var/lib/jenkins/workspace/touchanimtn/build.xml

BUILD FAILED
/var/lib/jenkins/workspace/touchanimtn/build.xml:83: Cannot find /opt/android-sdk-linux-ics/tools/ant/build.xml imported from /var/lib/jenkins/workspace/touchanimtn/build.xml

Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE

###################################################################################

I also tried by putting "android-sdk-linux-ics" into home folder but gave same error. 我也尝试将“android-sdk-linux-ics”放入主文件夹,但同样的错误。

Please, Give me the correct solution for this error. 请给我这个错误的正确解决方案。

您的Android SDK的根目录不在/opt/android-sdk-linux-ics (即tools目录应该在那里,没有中间目录),或者SDK确实存在,但是jenkins用户没有'有权访问它。

This is a good question that more people will face when installing Jenkins on a linux system where the android SDK was installed before. 这是一个很好的问题,在安装Android SDK的Linux系统上安装Jenkins时会遇到更多人。

The problem is either that the path to the android SDK is not correct (1) or insufficient permissions for the jenkins user to access the android SDK installation path (2). 问题是android SDK的路径不正确(1)或jenkins用户访问android SDK安装路径(2)的权限不足。

1) Path : Double check the path on your ant build step for the failing jenkins project. 1) 路径 :对于失败的jenkins项目,请仔细检查ant构建步骤的路径。 Go to the ant build step and click advanced. 转到ant build步骤,然后单击advanced。 There it should have sdk.dir=SOME/PATH listed in the properties field. 它应该在属性字段中列出sdk.dir = SOME / PATH。 For multiple values make sure you expand the field and use a new line per value. 对于多个值,请确保展开字段并为每个值使用新行。 Also don't include the -D to your argument since Jenkins will do that for each line. 也不要在你的参数中包含-D,因为Jenkins会为每一行做到这一点。

2) Permissions : Double check the permissions on the android-sdk folder listed there. 2) 权限 :仔细检查那里列出的android-sdk文件夹的权限。 Use ls -l to get a list of current permissions and chmod to update the permissions if needed. 使用ls -l获取当前权限列表,使用chmod更新权限(如果需要)。

Notes: 笔记:

It's always a good idea to switch to the jenkins user on your system and test the failing commands from the shell yourself. 切换到系统上的jenkins用户并自己测试shell中的失败命令总是一个好主意。

sudo su jenkins

I had this kind of error also when I enabled security on my jenkins configuration. 当我在jenkins配置上启用安全性时,我也遇到了这种错误。 You can disable security without loosing settings by stopping the jenkins service, renaming the config file and restarting the service. 您可以通过停止jenkins服务,重命名配置文件并重新启动服务来禁用安全性而不会丢失设置。

sudo service jenkins stop
sudo mv /var/lib/config.xml /var/lib/config.xml.backup
sudo service jenkins start

I didn't check in depth what user should get permissions in that case but I know reverting this change fixed the issue. 在这种情况下,我没有深入检查用户应该获得权限,但我知道还原此更改可以解决问题。 Also I could still execute the ant scripts with the jenkins user as listed before. 此外,我仍然可以使用之前列出的jenkins用户执行ant脚本。

This questions is very similar: Building android project from jenkins under linux - build fails, cannot find imported build.xml 这个问题非常相似: 在linux下构建来自jenkins的android项目 - 构建失败,找不到导入的build.xml

Might help someone. 可以帮助别人。

Wherever ANDROID_HOME/platforms pointing to 无论ANDROID_HOME /平台指向哪里

  1. Reach in finder 到达发现者
  2. bring get info 带来获取信息
  3. add Jenkins user and 添加Jenkins用户和
  4. give read access. 提供读取权限。

This solved my problem of build.xml not found error. 这解决了我的build.xml未找到错误的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM