1. The installationjenkins1.1. To directlywebsiteDownload the installation package and use the installation package to install 1.2. YesHomebrewInstall using the command line
1. Install Homebrew $Ruby-e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"Install Jenkins $brew install JenkinsCopy the code
  • jenkinsNeed to bejavaEnvironment, if not installed will be prompted,Java Installation Address

If all goes well, open your browser and type http://localhost:8080/ to see that Jenkins is up and running, and if you change the port you set later. Next, after Jenkins is opened, a page for filling in the password will be displayed as shown in the picture below. The place where the password is stored is the directory in red font on the picture

Then input the password we obtained into the Administrator password, you can enter the following interface, and then install some recommended plug-ins on the left. During the installation process, some plug-ins may fail to be installed, it is strongly recommended to click the lower right corner to retry until the recommended installation is complete

After the plug-in is installed, it may not automatically jump. Refresh the page. Register on the refreshed page and enter the user name and password

  1. The installationjenkinsPlug-in if you want to useJenkinsPlugin build project, need to install some before starting new projectJenkinsPlug-in, select the plug-in we need to install in the optional plug-in
1. Xcode integration
2. GIT plugin
3. GitLab Plugin
4. Gitlab Hook Plugin
5. Keychains and Provisioning Profiles Management
Copy the code

Today we use the Execute Shell shell script to build the project

  1. jenkins3.1. Build a free style software project

    3.2. Generalparameter

    You can set the retention days and maximum number of retained packets. These can be adjusted as required

  • jenkinsThe plug-in configures multiple projectsextended choice parameterPlug-ins are mainly built with multiple checkboxes to select the project modules to be built

    3.3. Source control

    Triggers can be customized in many ways, depending on the needs of the projectCan be omitted

  • Timed builds: no matterSVNorGitThe scheduled build task is performed if the data is changed or not
  • pollingSCM: as long asSVNorGitIf the data is updated, the content in the build task schedule is5The meanings of parameters from left to right are as follows: ⦁1Parameters: minutesminuteValue,0 ~ 59⦁ first2Parameters: hourshourValue,0 ~ 23⦁ first3Parameter: daydayValue,1 to 31⦁ first4Parameter: monthmonthValue,1 ~ 12⦁ first5Parameter: weekweekValue,0 ~ 7.0and7Sunday is Sunday5Parameters can be set optionally, do not write dead parameters*The parameters are separated by Spaces. Such as:
"0 21 * * *"Represents an automated build every night at 21:0"0 * * * *"Represents a build at the 0th minute of every hour"H/5 * * * *"Build every 5 minutes"H H/2 * * *"Build every two hours"H H 30 * *"Build once every month on 30th"H(0-29)/10 * * * *"Every 10 minutes in the first half hour of each hour"0 8-17/2 * * 1-5"Monday to Friday, 8:00 to 17:00, every two hours"H H 1,15 1-11 *"Construction will be done on 1st and 15th of every month, except for DecemberCopy the code

shell
Xcode
Shell

  • iOSAutomatic packing —Jenkins ShellAs follows:
# #! /bin/sh
# # the project name
TARGET_NAME=NNAlgorithm
# # Scheme
SCHEME=NNAlgorithm
# # = = = = = = = = = = = = = = = = = = = = = = =
## Compile type
BUILD_TYPE=Release
## Current directory
SORCEPATH=${WORKSPACE}
# # the workspace name
SPACE=${WORKSPACE}/${TARGET_NAME}.xcodeproj
##xcarchive file path
ARCHIVEPATH=$SORCEPATH/build/$SCHEME.xcarchive
## IpA file path
EXPORTPATH=$SORCEPATH/build/$SCHEME
## exportOptions. plist specifies the path where the file will be stored
EXPORTOPTIONSPLIST=$SORCEPATH/build/ExportOptions.plist
Ipa path after export
EXPORTPATHIPA=$SORCEPATH/build/$SCHEME/$SCHEME.ipa

echo -e "============First Build Clean============"
## Clear the cache
## If the project uses cocoapods, '-project %s.xcodeproj' will be replaced by '-workspace %s.xcworkspace'
xcodebuild clean -project $SPACE -scheme ${SCHEME} -configuration ${BUILD_TYPE}
echo -e "============Build Clean============"
Output key information
echo -e "  TARGET_NAME    : ${TARGET_NAME}"
echo -e "  BUILD_TYPE    : ${BUILD_TYPE}"
echo -e "  SORCEPATH    : ${SORCEPATH}"
echo -e "  ARCHIVEPATH    : ${ARCHIVEPATH}"
echo -e "  EXPORTPATH    : ${EXPORTPATH}"
echo -e "  EXPORTOPTIONSPLIST    : ${EXPORTOPTIONSPLIST}"
echo -e "============Build Archive============"

## Export archive package
xcodebuild archive -project ${SPACE} -scheme ${SCHEME} -archivePath $ARCHIVEPATH
echo -e "============Build Archive Success============"

echo -e "============Export IPA============"
Export the IPA package
xcodebuild -exportArchive -archivePath $ARCHIVEPATH -exportPath ${EXPORTPATH} -exportOptionsPlist ${EXPORTOPTIONSPLIST}
echo -e "============Export IPA SUCCESS============"

## Compile completion time 20181030_0931
BUILD_DATE="$(date +'%Y%m%d_%H%M')"

# # info. Plist path
PROJECT_INFOPLIST_PATH="${SORCEPATH}/${TARGET_NAME}/Info.plist"
Get the version number
BUNDLESHORTVERSION=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" "${PROJECT_INFOPLIST_PATH}")
# # is build
VERSION=$(/usr/libexec/PlistBuddy -c "print CFBundleVersion" "${PROJECT_INFOPLIST_PATH}")
## IPA renaming rule Project name V Version _ year month day _ hour
IPANAME="${TARGET_NAME}V${BUNDLESHORTVERSION}_${BUILD_DATE}.ipa"
Ipa path after name change
EXPORTPATHNEWIPA=$EXPORTPATH/$IPANAME

echo -e "============Export end :${BUILD_DATE}= = = = = = = = = = = ="
echo -e "============IPA Old Name: ${EXPORTPATHIPA}= = = = = = = = = = = ="
echo -e "============IPA New Name: ${EXPORTPATHNEWIPA}= = = = = = = = = = = ="

# # IPA changed its name
cp $EXPORTPATHIPA $EXPORTPATHNEWIPA
echo -e "============Create New Name Success============"
## Delete old IPA
rm $EXPORTPATHIPA
echo -e "============Delete Old Name Success============"

#userKey and apiKey need to be looked up in dandelion's account Settings
userKey="xxx"
apiKey="xxx"
# Dandelion pack
curl -F "file=@${EXPORTPATHNEWIPA}" \
-F "uKey=${userKey}" \
-F "_api_key=${apiKey}" \
-F "isPublishToPublic=2" \
http://www.pgyer.com/apiv1/app/upload
Copy the code
  • ExportOptions.plist
<? xml version="1.0" encoding="UTF-8"? > <! DOCTYPE plist PUBLIC"- / / / / DTD PLIST Apple 1.0 / / EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>provisioningProfiles</key>
	<dict>
		<key>com.Y***ane</key>
		<string>azur***_dev</string>
	</dict>
	<key>method</key>
	<string>development</string>
	<key>signingCertificate</key>
	<string>iPhone Developer</string>
	<key>signingStyle</key>
	<string>manual</string>
	<key>teamID</key>
	<string>42***ZL</string>
	<key>compileBitcode</key>
	<false/>
	<key>uploadSymbols</key>
	<false/>
</dict>
</plist>
Copy the code
  • Method parameters in the PList file are as follows: app-Store, ad-hoc, Enterprise, development 3.7. Post-build operation

  • Email notification system, through system management → System Settings, email configuration

  • Set Jenkins address and administrator email address

  • Set sender information. The sender email address must be the same as the email address of the system administrator

  • Note: The Password in the figure above is the SMTP authorization key of the mailbox. So far, the content of the system management office has been configured

  • Configure Jenkins’ built-in email function (to test whether the email function is in normal use, you can not configure it, it does not affect)

    And the aboveExtended E-mail NotificationIf the configuration is the same, clickTest configurationReceived the message and displayedEmail was successfully sent, indicating that the mail configuration is successful. Then you can go to the specific configuration of the project and use it

  • Enter the project, then locate the post-build actions, click Add Post-build steps, and click Editable Email Notification

  • Now all the configuration is complete, click Apply and save, enjoy it!

Project Reply-to List: Enter multiple email addresses, separated by English commas, To whom the Project Recipient-list needs To be sent: Content Type: You can choose Html or Default, because the Default format we set in Jenkins system is Html Default Subject: The email subject can be written as: XXX project iOS package notification:$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS! $PROJECT_NAME Specifies the name of the build project. $BUILD_NUMBER Specifies the number to build. $BUILD_STATUS = $BUILD_STATUS = $BUILD_STATUS = $BUILD_STATUS = $BUILD_STATUS<hr/> This email is automatically delivered by the program, please do not reply! <br/>< HR /> Project name:$PROJECT_NAME<br/><hr/> Build number:$BUILD_NUMBER<br/>< HR /> Build status$BUILD_STATUS<br/><hr/> Trigger cause:${CAUSE}<br/><hr/> Build log address: <a href="${BUILD_URL}console">${BUILD_URL}Console /</a><br/><hr/> Build address: <a href="$BUILD_URL">$BUILD_URL</a><br/><hr/> Build report: <a href="${BUILD_URL}testReport">${BUILD_URL}testReport/</a><br/><hr/> Change set:${JELLY_SCRIPT,template="html"}<br/><hr/>
Copy the code
  1. Uninstalling Jenkins (Windows/Linux/MacOS)
  • If you are usingbrewIf yes, run the following command$ brew uninstall jenkins
  • Note: Jenkins modifies the work spaceIn the project configuration, click Advanced, select Use Custom Workspace, and enter the workspace path

Attached: my blog address