In this paper, Docker deployed Jenkins service to achieve automatic packaging, host environment is Ubuntu18.04, host using root identity

0. Install the Docker

Unless otherwise specified, all commands are executed on the host by default

curl -sSL https://get.daocloud.io/docker | sh
Copy the code

1. Install Jenkins – master

1. Download and run Jenkins Master image

docker run -d -p 18080:8080 -p 50000:50000 jenkins/jenkins:lts-jdk11
Copy the code

Open the startup log view,

docker logs 638cd
Copy the code

Find the following password and copy it, as shown below

Reference documentation

2. Jenkins Master configuration

At this point, open a browser and enter your_host: 18080, I was http://10.1.20.191:18080/, input according to their own conditions, the following using Jenkins: 18080 instead, if you don’t know using ifconfig

Paste the password intoAdministrator passwordBox, next step,

In the step of “customize Jenkins”, select the recommended plug-in and wait for the installation to complete. Then set up the administrator account.

2. Install the Android SDK and configure the data volume

1. Pull and start Thyrlian/Android-sdk

docker run -d --name sdkc -v /home/android-sdk:/opt/android-sdk:rw -v /home/gradle_caches:/root/.gradle/caches thyrlian/android-sdk
Copy the code

2. Change the SDK directory to readable and writable

Docker exec -- it SDKC bash -- chmod -- cR 777 /opt/android-sdk/Copy the code

Reference documentation

3. Install the Jenkins – agent

Browser open http://jenkins:18080/computer/new android_agent_01 node name input, check the fixed nodes, was determined

Fill in as shown and save

Copy the string after -secret

docker run -d --volumes-from sdkc:rw -e ANDROID_SDK_ROOT=/opt/android-sdk --init jenkins/inbound-agent -url http://hostip:18080 secret-string android_agent_01 # replace secret-string with the string you just copied, and hostip with your hostipCopy the code

Reference documentation

3. Configure the Jenkins task

  • Browser openhttp://jenkins:18080/view/all/newJobEnter the task nameproject1, choose the first oneFreestyle projectThat pointdetermine

  • In the source control section, select your project address as required. In this case, Git, enter the repository URLCredentialsAdd the account password and select, do not expand.

  • Check theAdd timestamps to the Console Output

  • The lastsave

4. Build projects

  • Find the task you just created and clickBuild immediately

  • You can click build serial number below to viewConsole outputView the logs, and finally view the installation package after building

5. Advanced

Due to the limitations of space and time, I will talk about it in the next chapter