安装 jenkins

安装 :
brew install jenkins

/Users/Shared/Jenkins/Home/workspace
image.pngd

卸载 jenkins

/Library/Application\ Support/Jenkins/Uninstall.command

下载完成:

image.png

ln -sfv /usr/local/opt/jenkins/*.plist ~/Library/LaunchAgents

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist

http://stackoverflow.com/questions/2643502/git-permission-denied-publickey
In a word, if your intent is to clone-only a repo, use HTTPS URL([https://github.com/{user_name}/{project_name}.git](https://github.com/%7Buser_name%7D/%7Bproject_name%7D.git)) instead of SSH URL (git@github.com:{user_name}/{project_name}.git), which avoids (unnecessary) public key validation.
https://github.com/AlanCheen/Climb.git 代替 git@github.com:AlanCheen/Climb.git

19:46:45 FAILURE: Build failed with an exception.
19:46:45
19:46:45 What went wrong:
19:46:45 A problem occurred configuring project ‘:app’.
*19:46:45
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

ANDROID_HOME 配置 android SDK 环境

ANDROID_HOME
/Users/yifeiyuan/Library/Android/sdk

GRADLE_HOME
/Users/yifeiyuan/.sdkman/candidates/gradle/current/bin/gradle

image.png

构建触发器

远程构建

首先要安装插件:Build Authorization Token Root Plugin

Poll SCM

这里我选Poll SCM,(H/5 H(9-23)
第一个参数代表的是分钟 minute,取值 0~59;
第二个参数代表的是小时 hour,取值 0~23;
第三个参数代表的是天 day,取值 1~31;
第四个参数代表的是月 month,取值 1~12;
最后一个参数代表的是星期 week,取值 0~7,0 和 7 都是表示星期天。
如H/5
* 表示的就是每5分钟检查一次源码变化。

配置

邮件配置:安装 Email Extension Plugin 插件

插件:
Gradle
Git

CVS Plugin

Git Tag Message Plugin

Git Changelog

AnsiColor(可选)这个插件可以让Jenkins的控制台输出的log带有颜色(就和linux控制台那样)

坑一:

SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

jenkins 并不知道 SDK NDK 的路径,local.properties不会提交到 git 环境去,所以需要本地配置环境变量

解决方案:配置 android SDK 环境
ANDROID_HOME /Users/yifeiyuan/Library/Android/sdk

坑二:

配置了 SDK 环境 但是依然报SDK 找不到的错误

可能jenkins对这个目录没有权限,最后用 brew install jenkins 来重新安装了一遍jenkins 发现解决了。

坑三:

插件安装失败

可能是网络问题

直接去官网搜索插件,下载到本地后上传。(注意插件的依赖关系)

资料

http://debugtalk.com/post/iOS-Android-Packing-with-Jenkins/

http://stackoverflow.com/questions/5784329/how-can-i-make-jenkins-ci-with-git-trigger-on-pushes-to-master

http://www.jianshu.com/p/ad018160aff9

http://blog.sctux.com/?p=549