ios jenkins_如何使用Jenkins和Fastlane制作iOS点播构建系统

ios jenkins

by Agam Mahajan

通过Agam Mahajan

如何使用Jenkins和Fastlane制作iOS点播构建系统 (How to make an iOS on-demand build system with Jenkins and Fastlane)

This article is about creating iOS builds through Jenkins BOT, remotely, without the need of a developer.

本文旨在通过Jenkins BOT远程创建iOS构建,而无需开发人员。

Before starting, I want to say that this is my first article. So feel free to leave a comment if something can be improved :)

在开始之前,我想说这是我的第一篇文章。 如果可以改进,请随时发表评论:)

为什么这是个好主意? (Why is this a good idea?)

When a developer makes a feature, they QA test it before pushing it to production. So a build has to be shared with the QA team with some test configurations.

当开发人员创建功能时,他们会先对其进行质量检查,然后再将其投入生产。 因此,必须通过一些测试配置与质量检查团队共享构建。

Xcode (the IDE) takes a significant amount of time to compile and generate this build. This means that any person that needs the build would have to install the IDE, clone the repository, create a signing identity and certificate and then create the build themselves. Or depend on the developer to create one for them.

Xcode(IDE)需要大量时间来编译和生成此版本。 这意味着需要构建的任何人都必须安装IDE,克隆存储库,创建签名身份和证书,然后自己创建构建。 或者依靠开发人员为他们创建一个。

During the build creation process, the IDE is unusable. This severely impacts the productivity of the developer. In my company, the average build time of an .ipa is around 20 mins. On average, a developer makes 2–3 builds daily.This means 5 working hours a week get wasted.

在构建创建过程中,IDE不可用。 这严重影响了显影剂的生产率。 在我的公司中,.ipa的平均构建时间约为20分钟。 平均而言,开发人员每天进行2-3次构建,这意味着每周要浪费5个工作小时。

But what if there was an automated system which could generate the builds on its own? This would free the developers from this responsibility. It would also make it possible for anyone to get a build easily.

但是,如果有一个可以自行生成构建的自动化系统呢? 这将使开发人员摆脱这种责任。 这也将使任何人都可以轻松获得构建。

Jenkins is one of the solutions to our problem.

詹金斯是解决我们问题的方法之一。

Making builds easily available to testers and developers ensures that people are able to test features faster and ship to production more easily. This improves the productivity of development teams. It also improves the quality of products pushed to production.

向测试人员和开发人员轻松提供构建版本可确保人们能够更快地测试功能并更轻松地将其交付生产。 这提高了开发团队的生产力。 它还提高了推向生产的产品的质量。

现在开始吧。 (Let’s get started now.)

先决条件 (Prerequisites)

You will require:

您将需要:

  • macOS Machine (it is better to run it on Mac products)

    macOS机器(最好在Mac产品上运行)
  • 10 GB of drive space (for Jenkins)

    10 GB的驱动器空间(用于Jenkins)
  • Java 8 installed (either a JRE or Java Development Kit (JDK) is fine)

    已安装Java 8(可以使用JRE或Java开发工具包(JDK))

    Java 8 installed (either a JRE or Java Development Kit (JDK) is fine)http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

    已安装Java 8(可以使用JRE或Java开发工具包(JDK)都可以) http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Additional Plugins to be installed

要安装的其他插件

  • homebrew

    自制
  • wget

    get
  • RVM Plugin

    RVM插件

    RVM PluginInstallation guide

    RVM插件安装指南

    RVM PluginInstallation guidehttps://rvm.io/rvm/security

    RVM插件安装指南 https://rvm.io/rvm/security

Make one Branch with a file in it with the name Jenkinsfile with sample code:node { sh ‘echo HelloWorld’}Let's name it jenkins-integration. Will come back to this later.

使用示例代码在其中创建一个名为Jenkinsfile的文件的分支: node { Jenkinsfile sh 'echo HelloWorld' }其命名为jenkins-integration 。 稍后会再谈到。

  • Install Xcode on your machine from the App Store

    从App Store在计算机上安装Xcode
  • Install Fastlane on your machine. Jenkins will internally use fastlane commands to generate builds.

    在计算机上安装Fastlane。 Jenkins将在内部使用fastlane命令生成构建。

Now let’s go through it step by step.

现在,让我们逐步进行操作。

步骤1.在您的计算机上安装Jenkins (Step 1. Install Jenkins on your machine)

You can install on a MacBook or mac-mini. Mac-mini is preferred as it can be kept alive.

您可以安装在MacBook或mac-mini上。 Mac-mini是首选,因为它可以保持活动状态。

Download Jenkins -> https://jenkins.io/

下载Jenkins-&g t; https:// jenkins。 io /

Run java -jar jenkins.war --httpPort=8080 in the command line. If you’re getting an error in the terminal, try a different port (for example, 9090) as sometimes some ports are not available.

在命令行中运行java -jar jenkins.war --httpPort = 8080 。 如果终端出现错误,请尝试使用其他端口(例如9090),因为有时某些端口不可用。

Browse to http://localhost:8080 and follow the instructions to complete the installation.

浏览到http:// localhost:8080并按照说明完成安装。

Then add admin credentials and don’t forget them (as did I :P). Later you can go to Jenkins > Manage Jenkins > Manager Users and do your changes if needed.

然后添加管理员凭据,不要忘记它们(就像我:P一样)。 稍后,您可以转到Jenkins>管理Jenkins>管理员用户,并根据需要进行更改。

步骤2.创建您的第一个管道 (Step 2. Creating Your first Pipeline)

Create a new job and choose Pipeline Project.

创建一个新作业,然后选择Pipeline Project

To check out your project, under the section Pipeline, in Definition, choose Pipeline Script from SCM and in SCM choose Git

要检出您的项目,请在“ 管道 ”部分下的“ 定义”中,选择“ SCM中的管道脚本”,然后在SCM中选择“ Git”。

Then add your repo URL and add the credentials if its a private repo. In branches to build , add */jenkins-integration, the branch which we created earlier.

然后添加您的存储库URL,并在其为私人存储库的情况下添加凭据。 在build的分支中,添加* / jenkins-integration, 我们之前创建的分支。

Make sure Script Path is Jenkinsfile which we have created in our new branch. All the scripts will be written in this Jenkinsfile.

确保脚本路径是我们在新分支中创建的Jenkinsfile 。 所有脚本都将写入此Jenkinsfile中。

Click on Save and Jenkins will automatically scan your repo with the mentioned branch and will run the Jenkinsfile script.

单击“保存”,Jenkins将使用提到的分支自动扫描您的仓库,并将运行Jenkinsfile脚本。

Now we are ready to configure our Jenkinsfile to create builds

现在我们准备配置Jenkinsfile来创建构建

步骤3.将参数添加到作业 (Step 3. Add parameters to the Job)

User input is required for

需要用户输入

  • branch

  • environment (test or prod)

    环境(测试或生产)

For that we need to configure our project to take input parameters for a job.

为此,我们需要将项目配置为接受作业的输入参数。

Go to the Configure section and check This project is parameterised.Then select add parameter and add the same accordingly.

转到“ 配置”部分,然后检查“ 此项目已参数化” 然后选择添加参数并相应地添加。

When you click on save, you will see a new section on left side -> Build with Parameters. This will be the user interface to make builds.

当您单击保存时,您将在左侧看到一个新部分-&g t;。 用参数生成 。 这将是进行构建的用户界面。

These params will be used in our Jenkins script.

这些参数将在我们的Jenkins脚本中使用。

步骤3.配置Jenkins脚本 (Step 3. Configure Jenkins Script)

Will create multiple steps in our Jenkinsfile, each having one responsibility, and it will create a nice UI when it is built.

将在我们的Jenkinsfile中创建多个步骤,每个步骤都有一个职责,并且在构建时会创建一个漂亮的UI。

Go to your Jenkinsfile and replace the script with the following:

转到您的Jenkinsfile并将脚本替换为以下内容:

First, check out the branch through the parameter which we added earlier. Add your repo and GitHub token.

首先,通过我们之前添加的参数检出分支。 添加您的仓库和GitHub令牌。

Now the GitHub token should not be visible to others. To do this, go to Manage Jenkins-> Configure System ->Global properties and add githubToken as an environment variable.

现在,GitHub令牌对其他人不可见。 为此,请转到Manage Jenkins- &g t;。 配置系统 ->全局属性,并添加github令牌作为环境变量。

Then invoke the script to change the environment.

然后调用脚本以更改环境。

Next, invoke fastlane to clean (remove derived data, clean, delete .dsym files etc).

接下来,调用fastlane进行清理(删除派生数据,清理,删除.dsym文件等)。

If code signing is required, do that next using ad-hoc. You can use development or app store based on your needs.

如果需要代码签名,请使用ad-hoc接下来进行。 您可以根据需要使用开发应用商店

Next, create builds using the gym command in fastlane.

接下来,使用fastlane中的gym命令创建构建。

步骤4.运行作业 (Step 4. Run the Job)

Now our script is ready. Go to Jenkins and open Build with Parameters.

现在我们的脚本已经准备好了。 转到Jenkins并打开Build with Parameters。

It will start to run the script and will create a nice UI with multiple steps as mentioned in the Jenkinsfile.

如Jenkinsfile中所述,它将开始运行脚本并创建具有多个步骤的漂亮UI。

When the job is completed, go to the project Users/agammahajan/.jenkins/workspace/iOS_Build_Systemsand you will see that the .ipa has been created. Voilà!

作业完成后,转到项目Users / agammahajan / .jenkins / workspace / iOS_Build_Systems ,您将看到已创建.ipa 。 瞧!

Now you can share this build with others. You can use the Slack plugin to upload the builds to Slack if you want.

现在,您可以与其他人共享此构建。 如果需要,可以使用Slack插件将内部版本上传到Slack。

结语 (Wrapping up)

So to conclude here, we can see how easy it is to setup an automated bot which enables any person to trigger builds in just 2 steps: Give Branch->Test Environment-> Done.

因此,在这里总结一下,我们可以看到设置一个自动化的bot有多么容易,它使任何人都可以通过两个步骤触发构建:提供分支->测试环境->完成。

This has helped me and my fellow developers improve productivity and ship faster. It has also helped the QA team, so that they don’t have to depend on developers every time they need to test something. I hope it benefits you and your company also.

这帮助我和我的其他开发人员提高了生产率并加快了发货速度。 它也为质量检查团队提供了帮助,因此他们不必在每次需要测试某些东西时都依赖开发人员。 我希望它也能使您和您的公司受益。

From here, the possibilities are endless.

从这里开始,无限的可能性

  1. You can make scheduled jobs to generate nightly builds.

    您可以进行计划的工作以生成夜间版本。
  2. Upload builds directly to the App Store.

    将内部版本直接上传到App Store。
  3. Cache the builds, so builds with the same configuration are not generated again.

    缓存构建,因此不会再次生成具有相同配置的构建。
  4. Distributing the IPA in house for OTA (Over the air) installation.

    内部分发IPA以进行OTA(无线)安装。
  5. Make a CI-CD pipeline to run automated tests on every commit and make them production ready.

    建立CI-CD管道以对每个提交运行自动化测试,并使其准备就绪。

翻译自: https://www.freecodecamp.org/news/how-to-make-an-ios-on-demand-build-system-with-jenkins-and-fastlane-8eb1e02c73d1/

ios jenkins

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/393151.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

菜鸟也学hadoop(1)_搭建单节点的hadoop

其实跟官方的教程一样 只是 我想写下来 避免自己搞忘记了,,,,好记性不如烂笔头 首先确认自己是否安装了 java, ssh 以及 rsync 没有装的直接就 apt-get install 了嘛,,,java的不一定…

SP703 SERVICE - Mobile Service[DP]

题意翻译 Description   一个公司有三个移动服务员。如果某个地方有一个请求,某个员工必须赶到那个地方去(那个地方没有其他员工),某一时刻只有一个员工能移动。只有被请求后,他才能移动,不允许在同样的位…

CF758 D. Ability To Convert 细节处理字符串

link 题意:给定进制数n及一串数字,问在此进制下这串数能看成最小的数(10进制)是多少(如HEX下 1|13|11 475) 思路:此题要仔细思考细节。首先要想使数最小那么必定有个想法是使低位的数尽可能大即位数尽可能…

java 可能尚未初始化变量,java - 局部变量“变量”可能尚未初始化-Java - 堆栈内存溢出...

我得到这个错误。线程“主”中的异常java.lang.Error:未解决的编译问题:rgb2无法解析为变量它总是导致错误的rgb2数组。 如何解决这个问题呢?BufferedImage img1 ImageIO.read(file1);BufferedImage img2 ImageIO.read(file2);int w img1.…

leetcode1249. 移除无效的括号(栈)

给你一个由 ‘(’、’)’ 和小写字母组成的字符串 s。 你需要从字符串中删除最少数目的 ‘(’ 或者 ‘)’ (可以删除任意位置的括号),使得剩下的「括号字符串」有效。 请返回任意一个合法字符串。 有效「括号字符串」应当符合以下 任意一条 要求&…

软件工程——个人课程总结

软件工程,我就是冲着软件这两个字来的,开始我觉得我们大多数人也是这样的,能开发一款属于自己的软件应该是我们人生中的第一个小目标八,在上学期学完java语言后,我们自认为自己已经具备了开发一款小软件的能力&#xf…

规则网络_实用的网络可访问性规则

规则网络by Tiago Romero Garcia蒂亚戈罗梅罗加西亚(Tiago Romero Garcia) 实用的网络可访问性规则 (Pragmatic rules of web accessibility that will stick to your mind) I first started to work with web accessibility back in 2015, at an American retail giant. It h…

8-python自动化-day08-进程、线程、协程篇

本节内容 主机管理之paramiko模块学习 进程、与线程区别python GIL全局解释器锁线程语法join线程锁之Lock\Rlock\信号量将线程变为守护进程Event事件 queue队列生产者消费者模型Queue队列开发一个线程池进程语法进程间通讯进程池 转载:  http://www.cnblogs.co…

部署HDFS HA的环境

> 环境架构部署规划: bigdata1 NameNode ResourceManager Zookeeper JournalNode failOverController bigdata2 NameNode ResourceManager Zookeeper JournalNode failOverController bigdata3 DataNode NodeManager Zookeeper bigdata4 DataNode NodeManager &g…

php layui 框架,Thinkphp5+Layui高颜值内容管理框架

Thinkphp5Layui高颜值内容管理框架TP5Layui高颜值内容管理框架,新增API模块Thinkphp5Layui响应式后台权限管理系统专注打造好用的框架,极速开发,高效灵活,从架构上兼顾系统复杂度的迭代与需求多变。代码结构清晰,接口开…

leetcode657. 机器人能否返回原点

在二维平面上,有一个机器人从原点 (0, 0) 开始。给出它的移动顺序,判断这个机器人在完成移动后是否在 (0, 0) 处结束。 移动顺序由字符串表示。字符 move[i] 表示其第 i 次移动。机器人的有效动作有 R(右),L&#xff…

在Angular专家Dan Wahlin的免费33部分课程中学习Angular

According to the Stack Overflow developer survey 2018, Angular is one of the most popular frameworks/libraries among professional developers. So learning it increases your chances of getting a job as a web developer significantly.根据2018年Stack Overflow开…

select查询语句执行顺序

查询中用到的关键词主要包含六个,并且他们的顺序依次为 select--from--where--group by--having--order by 其中select和from是必须的,其他关键词是可选的,这六个关键词的执行顺序 与sql语句的书写顺序并不是一样的,而是按照下面的…

Python的Virtualenv(虚拟环境)的使用(Windows篇)2

Python的Virtualenv(虚拟环境)的使用(Windows篇) 2018年04月13日 11:35:01 D_FallMoon 阅读数 771 版权声明:版权所有 装载请注明 …

Loadrunner常用15种的分析点

1.Vusers:提供了生产负载的虚拟用户运行状态的相关信息,可以帮助我们了解负载生成的结果。 2.Rendezvous(负载过程中集合点下的虚拟用户):当设置集合点后会生成相关数据,反映了随着时间的推移各个时间点上并…

leetcode1442. 形成两个异或相等数组的三元组数目

给你一个整数数组 arr 。 现需要从数组中取三个下标 i、j 和 k &#xff0c;其中 (0 < i < j < k < arr.length) 。 a 和 b 定义如下&#xff1a; a arr[i] ^ arr[i 1] ^ … ^ arr[j - 1] b arr[j] ^ arr[j 1] ^ … ^ arr[k] 注意&#xff1a;^ 表示 按位异…

matlab的独立样本t检验,独立双样本检验的Matlab实现

Independent two-samples test in MatlabYang Runhuai1杨润怀(1987-)&#xff0c;男&#xff0c;讲师&#xff0c;生物3D打印Zhang Zhen1Yang Siqiao1Liang Zhen1梁振(1981-)&#xff0c;男&#xff0c;副教授&#xff0c;临床工程1、Life Science School, Anhui medical unive…

bi可视化工具_适用于您的BI解决方案的最佳数据可视化和Web报告工具

bi可视化工具通过智能数据分析使复杂变得简单 (Making the complex simple with smart data analysis) It is hard to overestimate the value of insightful analytics nowadays. All business processes have become data-driven: marketing, accounting, human resources, c…

Python os 属性(便于跨平台开发)

1、有助于跨平台开发的os模块属性 >>> tmp os.linesep >>> tmp \n >>> tmp os.sep >>> tmp / >>> tmp os.pathsep >>> tmp : >>> tmp os.curdir >>> tmp . >>> tmp os.pardir >&g…

第一个Hibernate项目

一、构建Hibernate项目 1.新建Java项目HibernateDemo1 2.导入Hibernate下的jar包&#xff08;lib->required下的所有jar包&#xff09;jdbc驱动包 3.导入hibernate.cfg.xml文件到src目录下&#xff08;在Hibernate文件目录中搜索*.cfg.xml&#xff09; 配置该文件如下&#…