Relevant concepts
Jenkins
- Jenkins, an open source continuous integration tool written in Java, provides continuous integration services for software development, which can monitor and trigger continuous and repetitive work. It has the characteristics of open source, supports multi-platform and plug-in extension, easy installation, interface management and so on. More on the reference [wiki] (en.wikipedia.org/wiki/Jenkin… .
Gitlab
- GitLab is an open source application developed using Ruby on Rails to implement a self-hosted Git project repository, which can be accessed via a Web interface. See Wikipedia for more information.
CI
- Continuous Integration (CI)
- As an important step in agile development, CI aims to keep products as high quality as possible while iterating quickly.
- CI is a development practice that increases project visibility and reduces the risk of project failure. For each code update, the correctness of the code and function should be tested through automated tests. Only the code that passes the automatic tests can be delivered and deployed later.
- CI is a way to better coordinate work between team members (production and research), better adapt to agile iterative development, automate and reduce human intervention, and ensure that the code submitted by team members can be successfully integrated at every point in time. It can be a good package for Android/iOS projects.
OTA
- Over-the-air (OTA) over-the-air download Technology. For details, see this document.
pgyer
- Dandelion (PGYER) provides mobile developers with a free App test and distribution service platform, supporting iOS and Android, simple two-step distribution of applications. There are similar fir. Im and so on.
The process structure
A process of Jenkins is simply drawn as follows:
IBM DeveloperThere is also a seemingly more complicated diagram on the web, as shown below
Continuous interaction flow chart:
Platform building
Jenkins installs and starts
IO /index.html download: mirrors.jenkins-ci.org/war/latest/…
Installation:
- Depending on the Java environment, install and configure the Java environment first
- Go to the official website to download Jenkins, double-click to install, if it is a Mac computer, it will automatically generate the global variable Jenkins
- Modify parameters: Jenkins + related parameters such as Jenkins — httpPort=8888 # Change the port number when the default port 8080 is occupied, or when a specific port is specified.
Start the
- Manual startup: java-jar jenkins.war
- Background boot (default port) : nohup java-jar jenkins.war &
- Background start (specified port) : nohup java-jar Jenkins. War -httpPort= 88&
- Background boot (HTTPS) : nohup java-jar Jenkins. War-httpsport = 88&
- Visit: http://localhost:8080/, localhost can be configured
Jenkins plug-in installation
Plug-in installation
Manage Jenkins -> Manage Plugins -> Available -> Search -> Click to install, as shown below
Practical plug-in
- IOS only: Xcode Integration
- Android specific: Gradle Plugin
- Gitlab Plugin: Gitlab Plugin and Gitlab Hook Plugin
- Git plugin: Git plugin
- GitBuckit plugin: GitBuckit plugin
- Credentials Plugin and Keychains and Provisioning Profiles Management
- FTP: Publish over FTP
- Script plug-in: post-build Script plug-in
- Modify Build name/description: build-name-setter/description setter plugin
- Obtain the commit log of the repository: Git Changelog Plugin
- Custom global variable: Environment Injector Plugin
- Custom Email Plugin: Email Extension Plugin
- Get the information about the current login user: build-user-vars-plugin
- Display code test coverage report: Cobertura Plugin
- To display the generated unit test reports, supporting all single test frameworks such as junit, NoseTests, etc. : Junit Plugin
- Other: GIT plugin/SSH Credentials plugin
Jenkins System Setup
Operations: Manage Jenkins -> Configure System
- Jenkins internal shell UTF-8 encoding Settings, as shown in the figure below
- Jenkins Location and Email Settings are shown in the figure below
- Email Notification. The Settings are as follows
How to send Email at every build with Jenkins
Jenkins Jobs configuration
Jobs Basic Configuration
Configure compilation parameters
For example, if you need to choose the package type by yourself, for example, if you need to compile different versions of packages such as Release, Debug, and Test, you need to configure the compilation parameters of Jobs, as shown in the following figure:
You can also configure other parameters, such as:
After the configuration is complete, the build screen will appear as follows:
How to configure a single Jenkins job to make the release process from trunk or branches?
Configure the rights of anonymous users
If you are too lazy to set up your own server for the later application release, you can use Jenkins’. However, you need to log in to access the posted link. In this case, you can set the access permission of anonymous users, so that anonymous users can download and access the app link provided by you.
Jobs source repository configuration (Gitlab as an example)
Configure SSH
Manage Jenkins -> Credentials -> Global Credentials (unrestricted) -> Add Credentials
- SSH: ssh-keygen -t rsa -c “Your email”. The password needs to be set during SSH generation. Id_rsa and id_rsa.pub(public key) are generated.
- Add key to SSH: ssh-add file name (admin password required)
- Add a public key to Gitlab: Copy the public key in id_rsa.pub and add it to Gitlab
- Add the public key from id_rsa.pub to Jenkins (private key option)
The new Job
In Jenkins, all tasks are organized in terms of “Job”. Before performing the operation, you need to create a Job. It is relatively easy to create a Job, just click “New Job” on the left side of Jenkins’ homepage, select Free-style Software Project, and enter the name of the Job.
Configuration Gitlab
In Jobs, the Gitlab source configuration is shown as follows: Git repository and build branch need to be entered, public key use the public key generated by SSH configuration above.
Jobs Sets trigger conditions
Jenkins supports a variety of trigger configurations including:
-
Periodically Build. An example of a timer is as follows:
H(25-30) 18 **1-5: Build H between 6:25 and 30pm on weekdays 23 **1-5: Build H(0-29)/15 **** : Build every 15 minutes for the first half hour (start time is uncertain) H/20 **** : Build every 20 minutes (start time is uncertain)
-
Build when a change is pushed to GitHub
-
Regularly detect code updates and Poll SCM if there are updates
Jobs Build method/compile configuration
Jenkins supports a variety of compilation configurations, including:
- Xcode: iOS build configuration (install Xcode Integration plug-in)
- Invoke Gradle script: Install Gradle plugin on Android
- Exceute Shell: script mode
If you use Xcode to build aN iOS application, configure the developer certificate. For details, see In-person signing and Integer issues. Exceute Shell is recommended, which is simple and effective.
Jobs Post-build processing
Artifacts and email notification configuration, see the following figure
The Email Extension Plugin can be used for detailed configuration, refer to this article
release
- FTP server, the most traditional way, can help dandelion or fir. Im (install the corresponding Jenkins plugin).
- Specialized Artifacts repositories, such as Nexus, Artifactory, etc.
- Object storage services: For example, Ali Cloud OSS, AWS S3, etc. Take Ali Cloud as an example. For details, see this article. Ali Cloud OSS is used as Artifacts in Jenkins Continuous integration solution
Of course, if you don’t want to publish your application to a third-party website and only want to host it on your own Intranet, you need to set up a server on your own Intranet. There are many ways to set up a server. You can use Apache or other services on your Mac.
IOS release may want to use OTA, please refer to this article and this step by step implementation of wireless iOS application installation (Intranet OTA)
Here is a shell script template I wrote (open source), which can be used for iOS plist file automatic creation and OTA simple release page automatic creation, refer to this link for source code, welcome Star.
Automatically generates a simple HTML interface, as shown below. Click Install to Install it
Note that after iOS7.1, you must use HTTPS, so you need to set HTTPS for Jenkins, refer to the Jenkins HTTPS Settings in the “postscript” below
Last Show
The final result after successful construction is as follows:
Afterword.
Signing and Certificate Issues (iOS)
- Set up code signing for iOS projects
- Install JENKINS into those pits in the release IPA
Email sending failure
- I encountered this problem in the actual construction process. After a while, I thought it was the email address of the company, but later I found it was only a small configuration problem.
- Click Advanced, select Use SMTP Authentication, and set the same parameters for Extended Email Notification as for Email Notification.
Jenkins Https Support
Jenkins Https command:
java -jar jenkins.war --help | grep -i httpsCopy the code
Note: The following uses a Mac address as an example.
KeyStore way
- Generation:
Keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore. JKS -storepass Password -dname"cn=WEB"Copy the code
- Use:
Java -jar Jenkins. War --httpPort=-1 --httpsPort=8080 --httpsKeyStore=/ directory /keystore.jks --httpsKeyStorePassword= passwordCopy the code
- Note: You need to import the “WEB” certificate for the first time. The import steps are as follows: Export certificate from Chrome -> Install Certificate -> Set Certificate “Allow All”. For the illustrated steps, see article 5 in the practical reference below.
Certificate way
- Generation:
sudo openssl genrsa -out server.key 2048 sudo openssl req -new -key server.key -out server.csr sudo openssl genrsa -out ca.key 1024 sudo openssl req -new -x509 -days 365 -key ca.key -out ca.crt sudo openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.keyCopy the code
- Use:
Start the Jenkins:
java -jar jenkins.war --httpsPort=8088 --httpsCertificate=/path/server.crt --httpsPrivateKey=/path/server.keyCopy the code
- Note/Note: 3 Common Name Enter the IP address or domain Name address. 4 Step 5 If I am Unable to access the./demoCA/newcerts is displayed “Directory” error, the solution is: in the current operation directory, create a demoCA\newcerts2 folder and then create an empty index. TXT file under the demoCA folder and create a serial file without suffix. Fill it with 01
Practical reference
- Starting and Accessing Jenkins
- Jenkins: Switch to SSL/ HTTPS mode Supports two HTTPS modes
- Installing and Configuring Jenkins KeyStore way
- Generating a self-signed SSL certificate using the Java Keytool Command (2004193) KeyStore method
- Distrustfully Install Self-signed Certificates & confide Them on OS X Certificate
- Free openSSL Generates an SSL Certificate in Certificate mode
- howto-jenkins-ssl
- Jenkins fails to Start due to HttpsConnectorFactory
- Problems encountered when OpenSSL generates server certificates
Refs
- Using Jenkins
- Building a software project
- Auto build and deploy iOS apps using Jenkins
- Continuous Integration for iOS with Jenkins
- GitLab Documentation
- Setup Jenkins + TestFlight for iOS apps
- Installing Jenkins on OS X Yosemite
- Build continuous integration environment quickly based on Jenkins
- Introduction to Jenkins
- Integrated OTA release in Jenkins
Copyright statement
SkySeraphbySkySeraphis licensed under aCreative Commons BY-NC-ND 4.0 International License.
The SkySeraph blog, created and maintained by Bob, uses a Creative Commons signature Reservation – Non-commercial – No Deduction 4.0 international license.
This article was first published on SkySeraph blog (Skyseraph.com). The copyright belongs to the author, welcome to reprint, but without the consent of the author must retain this statement, and the original link in a prominent place on the article page, otherwise the right to pursue legal liability.