I can believe fly.

Showing posts with label Jenkins. Show all posts
Showing posts with label Jenkins. Show all posts

Thursday, March 2, 2017

Jenkins集成iOS单元测试

xctest是xcode5自带的,另外对block的支持,mock的支持都还好。 之前叫做OCUnit
【准备】
jenkins接收junit的单元测试报告,因些需要安装一个将ocunit格式的测试报告转为JUnit.
OCUnit2JUnit项目地址: https://github.com/ciryon/OCUnit2JUnit
安装方式:sudo gem install ocunit2junit
--问题: ocunit2junit在 ruby 1.8.7的环境不能运行,我试着升级ruby到2.0.0安装OK。

【运行】
1. 你可以单独准备单元测试的schemes,比如名为proTests.  或着build工程的schemes里含有单元测试的target。
2. 在build环节中增加:xcodebuild -sdk iphonesimulator7.0 -destination OS=7.0,name="iPhone Retina (4-inch)" -scheme proTests -configuration Release test  2>&1 | ocunit2junit
-- 问题:在xcdoe 5.0环境下运行,如果未加-destination,刚会报错:

3. 输出报告:默认报告输出目录test-reports
【报告】
jenkins集成报告:点击“Add post-build action”选择“Publish JUnit test result report”,输入内容test-reports/*.xml保存设置
效果图如下:


参考资料:
https://developer.apple.com/library/ios/technotes/tn2339/_index.htmlD




创建于14年10月28









Tuesday, February 21, 2017

客户端项目发布build设计

方案一:在取代码之前创建TAG

缺陷:Jenkins的SVN插件会根据触发时间去计算该获取的修订号,新创建TAG不在此时间范围内,会取不到。

方案二:发布build前创建TAG并调用另一个任务取该TAG的代码

缺陷:发布build前会先取代码,此时默认获取trunk的代码或者选中的其它开发线,该发布build的SVN修订号会默认该trunk或其它开发线的值,而不是另一个任务取完TAG的SVN修订号。
取巧:
1. 创建一个空的TAG,以便不需要获取trunk的代码或者选中其它开发线,以便节省构建时间。
2. 获取TAG代码的任务,在取完TAG之后创建属性文件记录SVN修订存储在WORKSPACE工作区。其中,要确保发布build任务与取TAG代码的任务保持在同一个WORKSPACE。


jenkins设计 

第二步:Configure release build
发布build相关参数设置

检测发布tag与发布对象是否一致

创建一个发布tag

获取发布tag并记录SVN_REVISION

创建于20140626



Wednesday, February 15, 2017

Jenkins SSH 调查

man bash,看“Invocation”,关于交互式shell与非交互式shell的差别。还有登录shell与非登录shell的差别。

man ssh, 看到“If command is specified, it is executed on the remote host instead of a login shell.”

interactive login shell, or as a non-interactive shell with the --login option
     /etc/profile首先加载
     接着
     ~/.bash_profile, ~/.bash_login, and ~/.profile
     注意:是按顺序尝试,只加载遇到的第一个

When an interactive shell that is not a login shell is started
     /etc/bash.bashrc首先加载
     接着
     ~/.bashrc

/etc/bash.bashrc:
# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

/etc/profile:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), …).


实际上,为了避免代码重复,通常
.profile会source .bashrc
/etc/profile会source /etc/bash.bashrc


Login profile files

When the SSH slaves plugin connects to a slave, it does not run an interactive shell. Instead it does the equivalent of your running "ssh slavehost command..." a few times, eventually to run "ssh slavehost java -jar …".
Jenkins SSH Slave的登录:只会调用/etc/bash.bashrc和.bashrc,并且是non-interactive的。在原始的.bashrc的第一 句话,就return了。

http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html
Mac OS X 是例外:
An exception to the terminal window guidelines is Mac OS X’s Terminal.app, which runs a login shell by default for each new terminal window, calling .bash_profile instead of .bashrc. Other GUI terminal emulators may do the same, but most tend not to.

https://help.ubuntu.com/community/EnvironmentVariables
“
Note: Variable expansion does not work in /etc/environment.
”
这一句很重要,在/etc/environment里写 CLASSPATH=$CLASSPATH:xxxx:xxxxx,会导致Jenkins解析环境变量时死循环,就在于变量不展开。 

落款2014.02.26