This article mainly introduces the process of app continuously packaging and uploading dandelions using Jenkins and packaging script
1. Common commands
- Start Tomcat
cd /Users/mac/Library/ApacheTomcat/bin
./startup.sh
Copy the code
- If -bash:./startup.sh: Permission denied is displayed, the command cannot be executed because the user has no Permission. Run the chmod command to change the. Sh permission in the bin directory
chmod u+x *.sh
Copy the code
- To shut down Tomcat
./shutdown.sh
Copy the code
- View the Tomcat version information
sh catalina.sh version
Copy the code
- Start/restart Jenkins
1. Start the system using the cli
sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist
Copy the code
2. Start with Jenkins’ War package
java -jar jenkins.war
Copy the code
3, use the container to start
Install jenins to Tomcat, choose start on HTML pages, or directly enter the address http://localhost:8080/jenkins
- Stop Jenkins
1. Run the command
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
Copy the code
2. Stop in HTML
Open the web page http://localhost:8080/exit
Two, Tomcat common use
1. Download the Tomcat installation package from the Tomacat website
tomcat.apache.org/
I also use MAC version, I used tomcat version download.csdn.net/download/li under provided here…
2. Save the tomcat directory to the /Users/ computer name /Library/ directory and rename it ApacheTomcat
3. Start tomcat, open Terminal, and go to the bin directory of the ApacheTomcat directory
cd /Users/mymac/Library/ApacheTomcat/bin
Copy the code
Start the command
./startup.sh
Copy the code
If :-bash:./startup.sh: Permission denied is displayed, the command cannot be executed because the user has no Permission. Run the chmod command to change the. Sh permission in the bin directory
chmod u+x *.sh
Copy the code
After the modification, execute the restart command again:
./startup.sh
Copy the code
You can start
4. Enter http://localhost:8080 or http://local IP address :8080. The following figure shows that the installation is successful
5. Close Tomat
./shutdown.sh
Copy the code
For more commands, see the preceding commands
6. ApacheTomcat directory structure
1>bin: Stores the tomcat command
2>conf: stores tomcat configuration information. The server. XML file is the core configuration file
3> Lib: Support for tomcat software running JAR packages and technical support packages (such as servlets and JSPS)
4>logs: runtime logs
5> Temp: indicates the temporary directory
6> Webapps: Share resource files and Web application directories
7> Work: The directory where tomcat runs. JSP, where temporary files are stored when tomcat runs
7. Change the port number
The default port of the server is 8080. You can also change the port to a custom port. To avoid conflict with the system port, you must set the port to 1024 or higher, for example, 8888 Use notepad to open the server. XML file in the ApacheTomcat conf directory and change the port value 8080 to a custom port number (for example, 8020).
<Connector port="8020" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
Copy the code
After restarting the server, entering localhost:8080 is invalid. You need to enter localhost:8020 to open the server interface.
8. Password setting
Add the following code to the tomcat-users. XML file in the conf directory:
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
Copy the code
Open http://localhost:8080 again and go to the main tomcat interface. Click Manager App and enter the account and password to log in tomcat
9. Address of the Official Tomcat document
Tomcat.apache.org/tomcat-8.0-…
3. Jenkins
1. Download Jenkins package from the official website
Bitnami.com/stack/jenki…
The Jenkins package I used is also provided here
Download.csdn.net/download/li…
2. Jenkins installation and startup
The above documents will be in the Library after installation/get Jenkins Jenkins directory war file, directly into User/mymac/Library/ApacheTomcat/webapps/directory, and then start using the command line
sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist
Copy the code
Of course, you can also start with a Java command with the WAR package, then CD it to the current directory and use the command
java -jar jenkins.war
Copy the code
In fact, if you download the PKG package I provided above, it will automatically open the browser interface to configure and install Jenknis
3. Jenins installation exceptions
Be careful to install the JRE, which needs to pay attention to the version. If the version does not meet the requirements, Jenkins will not be able to access
It is better to use OracleJDK. At the same time, different versions of JKD may also have problems. Here provides the JDK version I use, JDK-8U144-MacOSX-X64. JKD website address www.oracle.com/technetwork…
4. Jenkins’ stop
Can open the browser input Jenkins address plus the exit secondary pages can exit, http://localhost:8080/exit
It can also be closed using the command line
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
Copy the code
5. Jenkins reboot
Input http://localhost:8080/restart in your browser
6, Jenkins reloads configuration information
Input http://localhost:8080/reload in your browser
7. Jenkins’ uninstall
Method 1: execute the command/Library/Application Support/Jenkins/Uninstall.com mand
Method 2: Go to the /Library/Application Support/Jenkins folder and double-click Uninstall.command
If you cannot access http://localhost:8080 again after the uninstallation is complete, the uninstallation is successful
8. Simple use of Jenkins
First we need to configure the JDK Gradle Maven environment we need
The JDK configuration
Gradle configuration
Maven configuration
There are other configurations that are also in this directory that are not configured yet because they are not needed for development
New project
This is where shell commands are configured
Once the configuration is complete, the build is ready
9, Jenkins official document address
www.w3cschool.cn/jenkins/
Iv. Install Gitlab
The instructions are the same as those on the official website, but there are some special instructions, so you can directly refer to this section to install.
1. Install GitLab dependencies
sudo apt-get install curl openssh-server ca-certificates postfix
Copy the code
Note that when installing PostFix, select “Internet Site” :
Then, “System Mail Name” fills in the IP address of your server (the figure below is just) :
Why the IP address? This is because, if you do not have a registered domain name, randomly fill in a domain name is not resolved. The domain name here has a great impact on GitLab. For example, if I randomly fill in “qsjn.com”, the project I created in GitLab will use “[email protected]” by default, which will bring unnecessary trouble. However, if you do have a domain name registration, it is advisable to fill in your domain name registration.
Download and install GitLab
The curl packages.gitlab.com/install/rep…
sudo bash sudo apt-get install gitlab-ee
3. Configure GitLab
GitLab uses ports 80, 8080, and 9090 by default. Unfortunately, Jenkins also uses port 8080 by default, so this step will change GitLab’s default ports to 11000, 11001, and 11002. If you still want to use the default ports, you can skip this step.
(1)
External_url ‘http://127.0.0.1’
Is amended as:
External_url ‘http://< your server address or domain name >:11000’
(2)
unicorn[‘port’] = 8080
Is amended as:
unicorn[‘port’] = 11001
(3)
#prometheus[‘listen_address’] = ‘localhost:9090’
Is amended as:
prometheus[‘listen_address’] = ‘localhost:11002’
4. Configure and start GitLab
Because we changed the configuration, we use the reconfigure command to reconfigure
sudo gitlab-ctl reconfigure
Copy the code
In addition, if you have not modified the configuration, you can use:
sudo gitlab-ctl start/stop
Copy the code
To start and close GitLab.
At this point, GitLab is installed
A detailed reference https://blog.csdn.net/ruangong1203/article/details/73065410
V. App continuous integration and upload to Dandelion (to be improved)
1. Now that we’ve configured Jenkins, all we need to do is write shell commands related to the project. Here’s the androidbuild.sh command
#! /bin/bash # Install the jq command before executing this script. Use brew install jq #jq command to parse and modify json files. Select * from 'projectName' where 'projectName' = 'jure' where 'projectName' = 'jure' where 'projectName' = 'jure' where 'projectName' = 'jure' where 'projectName' = 'jure' where 'projectName' = 'jure' where 'projectName' = 'jure ExportPath =~/Documents/app/android-${method}/${nowtime EnvType =$1 if [$# -eq 2] then envType=$1 if [$Publish_Market = true] then EnvType ='online' method='appstore' fi else Publish_Market=false fi echo '------ compile parameter -----' echo envType: ResetConfigJsonFile (){configFilePath=".. /config.json" cat $configFilePath | jq ".envType="${envType}"" > tmpConfig.json && mv tmpConfig.json $configFilePath if [ $Publish_Market = true ]; When then # launched the app marketplace, Be sure to close the debug panel cat $configFilePath | jq. "showDebugPanel = false" > tmpConfig. Json && tmpConfig mv. Json $configFilePath else The cat $configFilePath | jq. "showDebugPanel = true" > tmpConfig. Json && tmpConfig mv. Json $configFilePath fi} # to create the folder createDir(){ if [ ! -d "${exportPath}" ]; Then mkdir -p ${exportPath} fi echo ${exportPath}} # Print git commit information echoGitCommitId(){echo is about to start packing ~ CD.. Echo current build packages use Git branch for: ` Git the describe - contains all the HEAD | tr -s' \ n '` echo the current build packages using Git commit short id is: 'git rev-parse --short HEAD' echo /config.json CD PackageShellFiles} # Export the apK package to the specified file path buildApk(){ currentPath=`pwd` # cd .. /android # ios file directory #version.properties file directory path='.. /android' content=$(cat ${path}/version.properties) echo "$content" Save the versionCode variable versionCode = ` grep VERSION_CODE ${path} version. The properties | the cut - d '=' - f2 ` # versionCode + 1, AddVersionCode = 'expr $versionCode + 1' echo "versionCode====$versionCode" # *#VERSION_CODE=${addVersionCode}#g" ${path}version.properties content=$(cat ${path}version.properties) addVersionCode=`grep VERSION_CODE The ${path} version. The properties | the cut - d '=' - f2 ` echo "= = = = $content after replacement" echo $addVersionCode addVersionCode = = = = "" # Determine whether the versionCode is successfully accumulated. If [$addVersionCode -gt $versionCode] then # package apK #gradlew BUILD_TOOL_PATH='.. / Android 'echo' chmod -R 777 dev_crm_app2 #cd $BUILD_TOOL_PATH && ./gradlew assembleinsectRelease cd $BUILD_TOOL_PATH && ./gradlew assembleDebug openRootPath='.. Open the directory where the package is located. Of course, replace the absolute path in the program with your corresponding path. Program is running will not success # $openRootPath explorer '\ build \ outputs \ apk' # mobile packaging related documents mv ${path} / app/build/outputs/apk/debug/app - debug. Apk ${exportPath}/${projectName}.app.apk mv ${path}/app/build/outputs/apk/debug/output.json ${exportPath}/${projectName}.output. Json # restore path CD ${currentPath} # todo upload to dandelion sh uploadpackage.sh ${exportPath}/${projectName}.app.apk else echo "error: versionCode does not add 1" fi} #1. 2. Create the file directory and installation description file 3. #resetConfigJsonFile #echoGitCommitId createDir buildApkCopy the code
2. Upload dandelion command
#! / bin/sh # # set - e installation package file path packagePath readonly = $1 # dandelion configuration parameters APIKey = 428 c221853ed052ca74846e5bfe46dfe readonly UserKey = 38951568 cffd3426e9e8b5e59b667eca # dandelion account password # address: https://www.pgyer.com/ # account: # password: CheckPackagePath (){if [! -f "${packagePath}"]; Then echo '/ * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 37 m note \ \ [41, 033, 033 [0 m -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * /' echo 'package not exist. Please checkout file at Path:' ${packagePath} exit 1; fi} # upload installation package to dandelion uploadWithPgyer(){echo "Start upload pgyer -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - >" curlresponse = $(curl -i -f "file = @ $packagePath \" -f "uKey = $UserKey \" - F "_api_key = $APIKey" \ http://qiniu-storage.pgyer.com/apiv1/app/upload) echo '-- -- -- -- -- -- -- -- -- the installation package to upload the dandelion results -- -- -- -- -- -' echo $curlresponse } checkPackagePath uploadWithPgyerCopy the code
3. Similar to ios, I will improve it next time
\