Without further ado, let’s get straight to the text.

Step 1 Install Jenkins.

First of all, there are basically two ways to install Jenkins on the Internet, one is to install Jenkins by using PKG on the official website, one is to install Jenkins by downloading war package (similar to brew installation later), and the other is to install Jenkins by BREW. Brew installation is strongly recommended here. Here’s why:

1. PKG installation, many people will go all the way to next, after the installation, it will be found that Jenkins directory is in the shared directory, I do not know the non-ios project, but if Jenkins project is in the shared directory, then the coDesign code signature will cause a lot of permissions problems. Keychain access, profile file access, and so on, although there are many thieves on the Internet, such as copy, keychain to a file in a directory, copy profile to a folder, but when you go to copy, you will find, WTF? I don’t have this folder, brother. If you are like me, you think it is OK to create a new folder with the same name and path, then congratulations to you, even if it is not useful (I don’t know if it is my personal case). This is not to say that PKG cannot be installed, but you can’t go all the way to next, be sure to config the installation path at some point in the process, which step is specific, I forget brother, go to Baidu yourself.

2, why not use war package security, under normal circumstances, using war package installation is to use Java to run this war package, but I was what than ha ha bar this war package in the download directory, thought, every startup to run this war package, in case that day was deleted by which what? Yes, that’s one reason I think I’m a problem, so let me pass.

3, brew installation, not to say more, a line of command knock down, you can wait to flirt sister tea, all the benefits. If you do not want to use BREW, please CMD + W, go out and turn left, thank you.


To do a good job, he must sharpen his tools. Start preparing for installation.

The first is the network problem, ladder is a must, if you can tolerate the slow network and various network problems caused by the error, then you just fart.

If you don’t want to use ladders, you can always change ruby’s source to a domestic one, using the following command

1. Take a look at the current one
RubySource:
gem sources -lIf it’s not
https://gems.ruby-china.com/If it’s this one, don’t worry about it, it means it’s already domestic.


2. Remove foreign Ruby sources:
gem sources --remove https://rubygems.org/

3, Add domestic Ruby source:
gem sources -a https://gems.ruby-china.com/


4. Check whether the switch is successful:
gem sources -l

If you have SSR ladders, then great, here is how to let the terminal go agent,

Export ALL_PROXY=socks5://127.0.0.1:1080

Note:

1, 1080 is your SSR port number, if your SSR port number is not 1080, then all the network of your current terminal will hang up, just change the port number 1080 to your SSR socks5 port number, and then turn your SSR into global mode, otherwise the port may not be mapped. How to change? Go to SSR advanced Settings to change.

2. This command is valid only for the current terminal. If you create a new terminal, you need to run it again on the new terminal.

3. Other issues about letting terminals go proxy: see here

With the agent enabled, it’s time to install Jenkins

Thief simple fucking brother

Step 1: Upgrade Ruby (usually not the old system, can not ignore, if the following installation error, try to upgrade to fix.) : Upgrade method directly see here on the line, the net is also everywhere, their search also line.

Step 2: Install brew. Use the brew -v command if the version number is displayed, it indicates that the brew has been installed. (This should have it, generally do not care, if not installed,

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"Copy the code

Install with the command above.

Brew Cask install Java? Brew Cask install Java

Brew Install Jenkins

Step 5: If the installation is complete, Jenkins –version to see if the installation is successful.

Step 6: Command: Jenkins starts the Jenkins service, and after running, Jenkins starts it in the foreground. Some states of Jenkins running and some things that require you to input passwords will be directly reflected in the terminal. The advantage is that it is convenient for you to debug, but the disadvantage is that when you close the terminal, your Jenkins will be dead. Therefore, it is recommended to use it for debugging. Jenkins has built it, and directly start it in the background.

Insert a queue, list a few Jenkins common commands, copy and paste can be used directly

Since the launch of set up: sudo launchctl load - w/Library/LaunchDaemons/org. Jenkins - ci. Since the launch of plist cancel boot: Sudo launchctl unload - w/Library/LaunchDaemons/org. Jenkins - ci. Plist manual activation: Java - jar Jenkins. War background start (the default port) : War: nohup java-jar Jenkins. War: nohup java-jar Jenkins. War: nohup java-jar Jenkins. nohup java -jar jenkins.war -httpsPort=88 &Copy the code

After installing Jenkins and starting the service, open the viewer and input localHost:8080. If all the above steps are completed correctly, the Jenkins configuration interface will be opened. As follows:



The password here will appear on the terminal that just started the Jenkins service. Copy it over here. If you don’t find the terminal, or if you don’t find the password in the terminal (which is usually impossible), what if I don’t see the password? See that red file path up there? Open your own Jenkins file that shows the path, it will have the password, enter it, next.



At this point, don’t be a big fan, I will choose recommended plug-ins, 😄😄😄😄, and then the next step.



If the plug-in is not installed and it is red, look for a retry button in the screen and click on it again and again until it is green. And then the next step.




This interface with you more force force brothers, how to fill how to fill, you can fill in matsushima *, also can fill in Ozawa **, also can fill in *** and so on the name of many teachers. The next step



There’s nothing left to say about the interface, so just ignore it and go straight to the next step.

I can’t find the next interface, so I feel very sad: in short, please click “Save and continue” in the lower right corner for the next interface, and then the next step



Here we go. OK man, congratulations, Jenkins has set it up. Let’s start configuring the environment.


Install the fastlane

1. Create a window terminal and enable terminal agent. Refer to the above method

2. Run commands to install Fastlane

  1. Installation command:sudo gem install fastlane -NVor brew cask install fastlaneYou can choose one or the other.
  2. Install the bundle command on success:gem install bundler
  3. This command may take a long time to install, and you may feel that you are stuck. Be patient.
  4. Then continue the command:bundle update It could also be a time-consuming operation, depending on personality. Wait.

3. Configure FastLane

Once you have fastlane installed, you can start using it in your project

  1. CD to project directory (workspace file directory)
  2. Execute command:fastlane init(Initialize Fastlane and automatically configure some configuration files)
  • Init will ask you to enter the following information:


  • I won’t say much about what the 1,234 options represent, but Google Translate is easy to understand.
  • 3 is recommended. It will automatically configure some signature information of the APP for you
  • During the process, you will be asked to enter the Apple ID of the Apple development certificate. If there are multiple teams, you will be asked to select Team.



  • Type y, and Fastlane will download the existing metadata and screenshots. If we edit the downloadable.txt file, we will also upload the content to iTunes Connect when we upload the app to iTunes Connect using Fastlane.

  • You can still upload apps to the App Store using FastLane without doing anything by typing n.

  • In this case, I chose N, in case someone overwrites the metadata in iTunesConnect with local data and automatically submits it for approval, that person will be at risk.

  • If it turns upfastlane release, indicating that init succeeded.



  • There will be an extra one in the project directoryfastlane“Folder.



  • ifDeliverfile.screenshotsandmetadataDirectory not created, ready to rundeliver initTo create.

  • inDeliverfileFile, addforce trueOtherwise, it will be uploadediTunes connect“Will pop up onePreview.htmlA web page.

  1. Add dandelion plugin: commandfastlane add_plugin pgyerBe sure to CD the plugin to your project’s project directory, because when you add a plugin using Fastlane, you will automatically set some dependencies in the configuration file generated by init above to ensure that the plugin works properly. As for adding plugins to other directories, I can’t do it on my own machine. I can successfully add plugins, but when I use it in Jenkins, I will be prompted to say that the plugins can’t be found.


Configure the Fastlane appFile file

Copy and paste the following into appFile

# 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)

platform :ios do

before_all do
    ENV["FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD"] = "I write the independent password generated by APP here to solve the trouble of verifying and inputting the password in the following two steps. For specific methods of generating the password, please read or read the link I posted later."
  end



  desc "Push a new release build to the App Store"
  lane :releaseToAppStore do 
    build_app(workspace: "Your project filename. Xcworkspace", scheme: "Your Target name")
    upload_to_app_store(skip_screenshots: true,skip_metadata: true ) Skip_screenshots = true; skip_screenshots = true; skip_screenshots = true;
  end

lane :debugAdhocPgy doGym (scheme: "the name of the target", workspace: "Project file name.xcworkspace",

        include_bitcode: true,

        configuration: "Debug",

        export_method: "# output_directory: AD hoc","/Users/ XXX /Desktop/ ipA ", output_name: Specifies the name of the exported package. Ipa ", silent:false,

        include_symbols: true(api_key: "The key of the dandelion", user_key: "Dandelion key, go to Dandelion personal Settings, or go to Baidu also ok")

  end


lane :ReleaseAdhocPgy doGym (scheme: "the name of the target", workspace: "Project file name.xcworkspace",

        include_bitcode: true,

        configuration: "Release",

        export_method: "# output_directory: AD hoc","/Users/ XXX /Desktop/ ipA ", output_name: Name of the exported package. Ipa ", silent:false,

        include_symbols: true(api_key: "Dandelion key", user_key: "dandelion key")

  end



endCopy the code


Appfile file on the complete parameter configuration table want to in-depth understanding, direct Baidu bar, thief many.


Configuration Jenkins

First, enter localhost:8080 as follows:



Then click on Manage Jenkins on the left



Select Manage Plugins



In the upper-left search, search for the plug-in: Git Parameter

Find Git Parameter and click install directly in the lower left

Select restart after the installation is complete.

Then re-enter localhost:8080

I’m gonna go new item



When you have filled it in, click OK

Then follow the following picture to configure, because the parameters in the picture are associated with the parameters of appfile, so do not change, not responsible for success, if you want to know the specific meaning, you can baidu Fastlane command and Ruby syntax, the above parameters are also very well understand, guess should also guess out. This image is a bit long, click to see a larger image.



Configure the shell command as follows

Define the path to the jar package after the build
			path_target=target
			case $buildType in
				# Post Debug to dandelion
				Debug)
				fastlane debugAdhocPgy	
			;;Copy the code
				
				Release)
                    case $DeliveryType in
                    # post adhoc to dandelion
                    Ad-Hoc)
                      fastlane ReleaseAdhocPgy
                    ;;
                    # Release to Appstore
                    AppStore)
                    	fastlane releaseToAppStore
                    ;;
                esac
				;;
			esacCopy the code


After the configuration is complete, enter the project, click Build Parameter, select the configuration parameters for the response, and then upload the package as follows:

Click “Start Build” to start packaging the automatic build upload.

Let me tell you something about the parameters.


2. Select Debug or Release

2-1: Debug parameter, the version built in the third step will be built in the way of Debug regardless of whether Ad_Hoc or Release is selected, and uploaded to dandelion directly after construction

2-2: Release parameter:

  • 2-2-1: If Ad_Hoc is selected in step 3, it will be built in Release mode, exported in Ad_Hoc mode, and uploaded to dandelion.
  • 2-2-2: If you select Appstore in the third step, it will be directly uploaded to Appstore for submission for review.

This article mainly recommends the configuration of fastlane and sign parameters. The configuration of each parameter is introduced completely in it

Fastlane certificate Management: cert, Sigh

Reference article:

Fastlane for iOS continuous delivery

Jenkins build supports Git select branches