原创
2017-03-06php
关键点html
- Jenkins安装及配置
- Pipeline建立及配置
- ruby的版本管理工具rbenv安装
- fastlane安装
- 常见构建问题
- 相关工具及技术网站推荐
什么是持续集成 ?java
持续集成: 是一种软件开发实践,团队开发成员常常集成他们的工做,一般每一个成员天天至少集成一次,也就意味着天天可能会发生屡次集成。每次集成都经过自动化的构建(包括编译,发布,自动化测试)来验证,从而尽快地发现集成错误。团队发现这个过程能够大大减小集成的问题,让团队可以更快的开发内聚的软件。
参考文章:阮一峰日志node
经过pkg包安装 在 Mac 环境下,咱们须要先安装 JDK,而后在 jenkins 的官网 下载最新的 pkg 包,双击安装便可。安装好后在浏览器中输入 localhost:8080 会出现如图则表示安装成功:
ios
经过war包安装 若是Mac/windows上安装了Tomcat 能够直接将war包拷贝到tomcat/webapps,进入到war包所在目录启动Jenkins:git
java -jar jenkins.war --httpPort=8080
经过 [homebrew] (http://brew.sh/) 方式安装github
brew install jenkins
经过Docker安装
首先在Docker官网下载安装配置Docker, 而后参考此网站介绍在Docker环境下安装Jenkinsweb
默认配置 安装好Jenkins后,选择安装推荐的插件便可:
chrome
建立登陆用户
docker
Manage Jenkins
建立Node节点
分布式构建(在Jenkins的配置中叫作节点),分布式构建可以让同一套代码在不一样的环境(如:Windows和Linux系统)中编译、测试等。
Master节点:至关于Server的概念
Slave节点:至关于Agent的概念
更多介绍请查看Jenkins Master/Slave
配置Node时几个重要参数介绍
- Name:节点名称
- Description:节点描述,支持中文
- Remote root directionary:节点的根目录
(注意:若是目录不存在,会自动建立目录。可是必须对该目录有读写权限,不然会报错:hudson.util.IOException2: Failed to copy xxxx)
- Labels:标记(又叫作标签)用来对多节点分组,标记之间用空格分隔.例如'iOSMobile AndrodMobile',将会把一个节点标记上'iOSMobile'和'AndrodMobile'.
- Launch method:运行方式有四个选项。建议选择第一、2种方式配置。详细以下: 【推荐】Launch slave agents on Unix machines via SSH 在Unix(包括Linux)机器上通 过SSH通道链接节点 (适用于Unix和Linux)
Host:节点主机的ip地址
Credentials:凭据(若是为空或者不可选择,请在系统管理→Manage Credentials中配置。
Port:端口默认22
在mac上计算机已经安装了ruby,在终端下输入命令:ruby --version
为了能更好的管理ruby版本,咱们使用rbenv工具
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv $ cd ~/.rbenv && src/configure && make -C src
安装成功后执行 rbenv init
按照终端输出的提示将 eval "$(rbenv init -)"
拷贝到指定文件(注意: 若是你是使用的iterm2 则拷贝至~/.zshrc 不然拷贝至./bash_profile
配置好之后,从新开启一个终端,咱们安装ruby 2.4.0版本
$ rbenv install -l # 查看ruby可用版本 $ rbenv install 2.3.0 # 安装ruby2.3.0 $ gem install bundler # 安装ruby gems $ rbenv rehash # 成功操做后,执行rehash操做 $ rbenv global 2.3.0 # ruby 系统全局环境 $ rbenv local 2.3.0 # ruby 本地环境 $ rbenv shell 2.3.0 # ruby做用于当前终端环境
node('Mobile') { stage('SVN Checkout') { checkout([$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: [[credentialsId: 'sclocman', depthOption: 'infinity', ignoreExternalsOption: true, local: '.', remote: 'svn://svn地址信息']], workspaceUpdater: [$class: 'CheckoutUpdater']]) sh "svn upgrade #{HOME}/.JenkinsAgent" } stage('Unit Testing') { dir('./fastlane') { // sh 'source ~/.bash_profile && bundle exec fastlane ios test' } } stage('Generate Test Report') { dir('./fastlane') { // sh 'source ~/.bash_profile && bundle exec fastlane ios test_report' } } stage('Update the Version NO.') { dir('./fastlane') { sh 'source ~/.bash_profile && bundle exec fastlane ios update_version' } } stage('Functional Testing') { dir('./fastlane') { sh 'source ~/.bash_profile && bundle exec fastlane ios function_test' } } stage('Build') { dir('./fastlane') { sh 'source ~/.bash_profile && bundle exec fastlane ios build config:Debug' } } stage('Release Version') { dir('./fastlane') { sh 'source ~/.bash_profile && bundle exec fastlane ios deploy config:Debug' } } }
$ xcode-select --install #确保安装了最新的xcode command line tools $ sudo gem install fastlane -NV # 安装fastlane
$ fastlane init
按照提示进行便可。成功后你的目录工程下会多出一个fastlane目录,更多fastlane使用请参考。
找不到打包的ipa,形成不能上传蒲公英,couldn't open file "/Users/apple/.JenkinsAgent/workspace/locmanYZY-Test/fastlane/fastlane_build/fastlane/result/archive/Debug/ipa/Debug.ipa
缘由:未在Pipeline配置打包stage
打包未签名,Code signing is required for product type 'Application' in SDK 'iOS 10.2
缘由:Agent机器为配置对应证书及Profile
Could not find lane 'ios build_app_for_simulator'. Available lanes: ios test, ios build_ipa, ios build_simulator_app, ios deploy_to_pgyer, ios update_build_number 缘由:stage配置执行的lane找不到,直接参考提示修改便可

构建版本error #4
Runnning script '[CP] Embed pods Frameworks' 缘由:须要证书受权
构建版本error #5
curl error SSLRead
配置curl ssl:
$ php -i |grep "SSL Version" #看看SSL Version的信息 SSL Version => SecureTransport // 执行下面命令 $ brew tap homebrew/dupes $ brew tap homebrew/versions $ brew tap homebrew/php $ brew install --with-openssl curl $ brew install \ --with-apache \ --with-homebrew-curl \ --with-homebrew-openssl \ --without-snmp php55 $ php -i | grep "SSL Version" #若是看到如下,则操做成功 SSL Version => OpenSSL/1.0.1j ```  #### 结后语 - **相关工具推荐** * [iTerm 2](http://www.iterm2.com/downloads.html) 一款能够替代Mac自带终端的软件,为了使其用起来顺手能够参考[Mac配置终端环境 iTerm2 + Zsh + Oh My Zsh + tmux](http://www.tuicool.com/articles/FFN7Vbq) * [PostMan](https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en) 接口测试工具,属于chrome插件,也能够是APP模式,可是须要安装了chrome才能使用 * [Atom](https://atom.io/) 用法等参考[Atom中文社区](https://atom-china.org/) ,[知乎](https://www.zhihu.com/question/22867204)上有对此款软件的评价 * [Sublime](http://www.sublimetext.com/) * [alfred](https://www.alfredapp.com/) 用了你就知道有多方便,付费版本功能更多,能够自定义overflow - **相关技术网站推荐** * [Thoutworks技术雷达](https://www.thoughtworks.com/radar) 同时能够参考Thoutworks公司[逸言](http://agiledon.github.io/blog/2013/04/17/thoughtworks-developer-reading-radar/)的博客 * [infoQ](https://www.infoq.com/) 实践驱动的社区资讯站点,致力于促进软件开发领域知识与创新的传播,包含有:架构、移动、运维、云计算、AI、大数据、容器等技术新闻,有中文版面 * 有问题上 [stackoverflow](http://stackoverflow.com) * [ruby](https://ruby-china.org/) 了解学习相关ruby技术 * iOS 测试相关技术学习 | 技术框架 | 单元测试 | 截屏测试 | 功能测试 | |--------| ------------- |:-------------:| :--------:| | Quick | ✅ Swift(BDD)| ❎ | ❎ | | Nimble | ✅ Swift(断言)| ❎ | ❎ | | KIWI | ✅ OC(BDD/断言/Mock)| ❎ | ❎ | | FBSnapshotTestCase| ❎ | ✅ | ❎ | | Calabash | ❎ | ❎ | ✅ | | Appium | ❎ | ❎ | ✅ | 本文参考了不少blog、github、stackoverflow的文章及问题,感谢做者的分享!特别感谢ThoughtWorks的周教练耐心指导!本文提到的**后续补充问题及深刻详解**将会持续更新,也欢迎各位修改文档使其更加丰富细致。