Setting up Jenkins environment

Install Jenkins (Java environment required)

Download it from Jenkins’ official website or from tsinghua University’s open source mirror website

The Jenkins package version I installed myself is jenkin-2.121.1.pkg

After installation, Safari may open automatically. If it doesn’t, open your browser and type http://localhost:8080

If an error message is displayed indicating that the server cannot be connected, restart the computer. Then enter http://localhost:8080 to go to the login page.

According to the prompt, find/Users/Shared/Jenkins/Home/the directory, find secrets file, display, setting everyone can read and write permissions, and find initialAdminPassword file, also let go of the access, copy the password, log in, Enter your user name, password, email, etc. Finally click Save and Finish.

Related plugins that Jenkins packaged

  1. Certificate management plug-in link

  2. Xcode plug-in link

  3. Script execution plug-in link

  4. Git plugin links

Install the plugins and restart Jenkins. Here are a few things about Jenkins

1, restart Jenkies http://localhost:8080/restart 2, reload the configuration information for http://localhost:8080/reloadCopy the code
Certificate Management Plug-in

Note that developer is only a certificate for test development,password must fill in the correct password of the key string, the Code Signing Identity is from the key to find the corresponding certificate, and then display the brief description to copy, this Identities need to fill in two items less. The Code Signing Identity is used by Code Signing.

/Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profiles
Copy the code

Move copy related files

Move the required files to the appropriate directory

A, / Users/username/Library MobileDevice folder copy to/Users/Shared/Jenkins/Library

Note: Is the MobileDevice copy this folder in the past, rather than in the MobileDevice file, / Users/Shared/Library/Jenkins directory is not MobileDevice this folder, So start by creating a MobileDevice folder.

Input at terminal

sudo mkdir /Users/Shared/Jenkins/Library/MobileDevice
sudo cp -r /Users/xxx/Library/MobileDevice/ /Users/Shared/Jenkins/Library/MobileDevice/
Copy the code

If there is no mobileDevice folder, xcode is not installed

Second, will/Users/username/Library/Keychains/login. Keychain and login. Keychain – db copy these two files to/Users/Shared/Jenkins/Library/Keychains folder below
Note: The login.keychain-db file is not available for Mac OS 10.12 or lower. You only need to copy the login.keychain file.Copy the code

Enter:

cd /Users/Shared/Jenkins/Library/
sudo mkdir Keychains
sudo cp /Users/xxx/Library/Keychains/login.keychain ./Keychains/
sudo cp /Users/xxx/Library/Keychains/login.keychain-db ./Keychains/
Copy the code

Copy the login.keychain to the desktop. If login.keychain does not exist, change login. keychain-db to login.keychain

Key string permission, ~/Library permission and computer user management permission

Click Display Introduction to change related permissions

4, Find the Library folder, set the share and access permissions, everyone can read and write, and apply to the lower directory

Start building the project

Build action, name click enter a task name, select Build a free style

Git pulls the code and uploats the relevant Git dependencies to the global variable

Copy this thing as a global variable to the appropriate location

Keychains and Code Signing Identities

The Code Signing Identity may not appear the first time you select it, so you can see it by saving the project and exiting

Upload dandelion related operations

Fastlane structures,

Introduce fastlane

Fastlane is an automated build tool for iOS and Android developers. It allows you to connect your App packaging, signing, testing, publishing, organizing, submitting to the App Store, and more to achieve a fully automated workflow. When used properly, It can significantly improve the development efficiency of developers.

Xcode7+ macOS or Linux with Ruby 2.0.0 +

Install the fastlane
$sudo gem install Fastlane ERROR: While executing gem... (Errno::EPERM) Operation not permitted - /usr/bin/commander Use: sudo gem install -n /usr/local/bin fastlaneCopy the code

CD to the appropriate directory, fastlane init and I chose 4. The directory structure is

Fastlane file code operation note: be sure to install the following command

fastlane add_plugin pgyer
Copy the code

# This file contains the fastlane.tools configuration # You can find the documentation at https://docs.fastlane.tools # # For a list of all available actions, check out # # https://docs.fastlane.tools/actions # # For a list of all available plugins, check out # # https://docs.fastlane.tools/plugins/available-plugins # # Uncomment the line if you want fastlane to Automatically update itself # update_fastlane default_platform(:ios) fastlane_version "2.99.0 Default_platform :ios lane :beta do gym(# output IPA name output_name: "QKiOS_IPA", # empty previous compilation information true: Is clean:true, # specifies the packaging method, Release or Debug configuration:"Debug", # specifies the output method to be used for packaging, Currently supports app-Store, package, ad-hoc, enterprise, development export_method:"development", /fastlane/build",) pgyer(api_key: "api_key", user_key:" user_key")Copy the code

Jenkins’ shell script

Perform pod operations first, if you install using Cocoapod

#bin/bsah - l

export LANG=en_US.UTF-8

export LANGUAGE=en_US.UTF-8

export LC_ALL=en_US.UTF-8

cd $WORKSPACE/

echo ++++++++++++++++++

#/usr/local/bin/pod install
/usr/local/bin/pod update --verbose --no-repo-update

echo begin
echo ++++++++++++++++++

Copy the code

Unlock the keychain

#bin/security - l
/usr/bin/security unlock-keychain -p q1234 ~/Library/Keychains/login.keychain-db
Copy the code

Fastlane does the packaging

#bin/bsah - l

export LANG=en_US.UTF-8

export LANGUAGE=en_US.UTF-8

export LC_ALL=en_US.UTF-8

cd $WORKSPACE/

pwd

PATH="/usr/local/bin:$PATH"

#Package operation
/usr/local/bin/fastlane beta 

Copy the code

Integrated successful display

Integrated console output successfully

Signs of Jenkin’s success

Problems encountered during integration

  1. The CodeSign signature failed, and the shell script to unlock keychain was executed. Procedure
CodeSign /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/QKiOS-ceqftwbkurbqjxfyflrsrfuzezvs/Build/Intermediates.noindex /ArchiveIntermediates/QKiOS/InstallationBuildProductsLocation/Applications/QKiOS.app```Copy the code