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.pswp.cn/news/393151.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/393151.shtml
英文地址,請注明出處:http://en.pswp.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; 配置該文件如下&#…