某小型公司持续集成工具Jenkins实践

发表于:2017-12-26 17:07

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:邵磊    来源:51Testing软件测试网采编

  前言
  本文可能是网上最全的一篇全端jenkins部署解决方案介绍的文章,一直以来,领导都想解决代码提交和打包问题,尤其是小公司,打包流程混乱,造成线上版本和代码库git或svn中代码不一致问题。加入jenkins阵营,解决众多发包难题,显得刻不容缓。
  研究过程
  刚开始,我一直在docker下安装jenkins,按时长租用阿里的主机,用阿里容器服务做实验,反复创建docker容器,建立多个jenkins节点。结果发现,在容器中配置各种变量比较复杂,各种开发环境不易快速部署,当然啦,是刚开始的对jenkins研究过少造成的。后来我采用了windows主机,配java、maven、Android环境,踩了一路坑,终于搞定了。但是我知道ios开发和编译必须使用mac系统,本来想增加一个jenkins节点来实现ios的编译。当配置好之后,我突然改变了主意,与其两台电脑开着,不如索性把整个jenkins部署到mac系统下(毕竟我们公司暂时没有c#工程)。于是,所有的操作,所有的环境我又折腾了一遍。下面我逐一讲解最终mac下实现全端jenkins持续集成,当然不包含c#,一路踩坑下来,我觉得这都不是事,流程都差不多。
  效果图
  jenkins首页
构建历史
  安装jenkins
  我个人比较喜欢新事物,所以建议使用较高版本,我使用的2.61,目前最新版是2.75。mac下使用brew安装,终端执行
  brew install jenkins等安装完成后,终端运行jenkins即可启动。
  jenkins
  安装 xcode
  这个比较简单,直接从appstore下载最新版即可。安装后,将公司项目拉入xcode,先保证项目在本机编译,这里我登录了app开发者帐号,以便下载各种证书及发布。
  安装 Android studio
  这个到这里下载www.android-studio.org/
  同理将本地项目拉入,运行。这一步主要是怕开发环境引起的坑,先把项目跑起来,后面坑会少点。
设置
    进入设置,复制出sdk文件路径,后面需要使用。我这里是/Users/Shaolei/Library/Android/sdk
sdk路径
  安装git
  因为我们公司用的是git,如果贵公司使用svn,则同理,只需保git或者svn命令可以敲出来即可。我这里的版本比较老,尽量使用新的,我懒得换了。
  mac:~ shaolei$ git version
  git version 2.11.0
 安装source tree
 这是一个非常好用的git可视化工具,改天会具体介绍它的强大功能。这款软件不是必须的,只是为了方便项目拉取,所以,你可以跳过此步骤。
  配置jenkins环境
  这里才是至关重要的一项,本文的核心
  配置插件
  下载插件
  1.Android Emulator Plugin  
   Starts an Android emulator with given properties before a build, then shuts it down after.
  2.build timeout plugin 
   This plugin allows builds to be automatically terminated after the specified amount of time has elapsed.
  3.Email Extension Plugin This plugin is a replacement for Jenkins's email publisher    
  4.Gradle Plugin This plugin allows Jenkins to invoke Gradle build scripts directly.
  5.Keychains and Provisioning Profiles Management This plugin integrates management of keychain and provisioning files for iOS and OSX projects.
  6.Maven Integration plugin This plug-in provides, for better and for worse, a deep integration of Jenkins and Maven: Automatic triggers between projects depending on SNAPSHOTs, automated configuration of various Jenkins publishers (Junit, ...).    
  7.Pipeline A suite of plugins that lets you orchestrate automation, simple or complex. See Pipeline as Code with Jenkins for more details.    
  8.Pipeline: GitHub Groovy Libraries Allows Pipeline Grrovy libraries to be loaded on the fly from GitHub.
  9.SSH Slaves plugin Allows to launch agents over SSH, using a Java implementation of the SSH protocol.
  10.Subversion Plug-in
  11.Timestamper
   Adds timestamps to the Console Output
  12.Workspace Cleanup Plugin This plugin deletes the project workspace after a build is finished.
  13.Xcode integration This plugin provides builders to build xcode projects, invoke agvtool and package .ipa files
  其中Android Emulator Plugin、Gradle Plugin是安卓必须插件;其中Keychains and Provisioning Profiles Management、Pipeline、Xcode integration是ios编译必须插件;其中Maven Integration plugin、SSH Slaves plugin是maven项目必须插件,其他的Email Extension Plugin这个是为了编译失败的时候通知具体提交代码开发人员邮件
  配置系统设置
  系统设置
  Local Maven Repository为maven仓库地址;如果本机没有安装maven,可能需要增加maven仓库;下面需要加入安卓环境变量,即上文中提到的那个sdk地址;
  这里配置github地址,邮件用户名密码,注意发件人的邮箱必须上面jenkins注册是管理员邮箱是一个,否则一直失败,这里是个坑。

上文内容不用于商业目的,如涉及知识产权问题,请权利人联系博为峰小编(021-64471599-8017),我们将立即处理。
21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号