I. Environment building

1. Jenkins installation

(1) Install JDK 1.8.0 first

Yum -y install java-1.8.0-openjdk-devel

Verify: Java-version

(2) Install Jenkins via yum command

See: PKG. Jenkins. IO/redhat /

1) sudo wget -o/etc/yum repos. D/Jenkins. Repo PKG. Jenkins. IO/redhat – stab…

2) sudo RPM –import pkg.jenkins. IO /redhat-stab…

3) Sudo yum install Jenkins

2. Install the plug-in

1) CD to the directory you want to download gradle

# wget services.gradle.org/distributio…

2) Unzip Gradle

# unzip gradle 6.1.1 – all. Zip

3) CD to the directory you need to download, first go to download the Android SDK, tools.android-studio.org/index.php/s… , upload it to a directory and decompress it

# tar – ZXVF android – sdk_r24. 4.1 – Linux. TGZ

4) Gradle and Android SDK configuration variables

Open System Administration-System Configuration, find global properties, check environment variables, and configure information as shown in the following figure

Configure the Android SDK and Gradle environment variables

    # cd /etc/profile.d/

    # vim android.sh

The editor

    export ANDROID_HOME=”/usr/local/android-sdk-linux”

Export GRADLE_HOME = “/ usr/local/gradle – 6.1.1”

export PATH=” ANDROIDHOME/tools:ANDROID_HOME/tools:ANDROIDHOME/tools:ANDROID_HOME/tools/bin: ANDROIDHOME/platform – the tools: ANDROID_HOME/platform – the tools: ANDROIDHOME/platform – the tools: GRADLE_HOME/bin: $PATH.”

Go to System Setup – Global Tools Configuration, configure gradle JDK and Git

5) Git plug-ins

Linux install git

   # yum -y install git 

Go to System Settings – Plug-in Management and enter git parameter to download the plug-in

Go to Android project Settings, parameterize the build process and create $BRANCH

Source code management, configuration warehouse address

3.Android parameter construction

According to the requirements of the company, the functions of dynamic packaging are: replace logo, application name, company official website, company name, startup page, company logo, etc.

Add the configuration to the Android project gradle.properties file. We are using Gradle package, where the configuration parameters will be assigned values. Gradle configuration: Pass all Job parameters as System Properties must be checked.

Set the following parameters:

3. Run shell to replace the image

cd ${WORKSPACE}

1. The RCE logo is used in PNG format

rce_ic_logo_file=”rce_ic_logo.png”

2. A small icon in the notification bar is displayed in PNG format

notification_small_icon_file=”notification_small_icon.png”

3. PNG image of the company logo

rce_ic_company_logo_file=”rce_ic_company_logo.png”

4. The startup page is in PNG format

rce_splash_bg_file=”rce_splash_bg.png”

The uploaded icon will be placed in the root directory of the current Jenkins project

if [ -f “$rce_ic_logo_file” ]; then

Replace the following resources, respectively

# 1. RCE application logo, images in PNG format rcekit/SRC/main/the res/drawable – xhdpi

  rce_ic_logo_path_base_xh=”${WORKSPACE}/rcebase/src/main/res/drawable-xhdpi”

  rce_ic_logo_path_image_xh=”${WORKSPACE}/imageeditor/src/main/res/drawable-xhdpi”

  rce_ic_logo_path_mip_hdpi=”${WORKSPACE}/rcekit/src/main/res/mipmap-hdpi”

  rce_ic_logo_path_mip_mdpi=”${WORKSPACE}/rcekit/src/main/res/mipmap-mdpi”

  rce_ic_logo_path_mip_xhdpi=”${WORKSPACE}/rcekit/src/main/res/mipmap-xhdpi”

  rce_ic_logo_path_mip_xxhdpi=”${WORKSPACE}/rcekit/src/main/res/mipmap-xxhdpi”

  rce_ic_logo_path_mip_xxxhdpi=”${WORKSPACE}/rcekit/src/main/res/mipmap-xxxhdpi”

  #convert -resize 512×512 rce_ic_logo.png rce_ic_logo.png

  cp rce_ic_logo.png ${rce_ic_logo_path_mip_xxxhdpi}

  #convert -resize 384×384 rce_ic_logo.png rce_ic_logo.png

  cp rce_ic_logo.png ${rce_ic_logo_path_mip_xxhdpi}

  #convert -resize 256×256 rce_ic_logo.png rce_ic_logo.png

  cp rce_ic_logo.png ${rce_ic_logo_path_mip_xhdpi}

  #convert -resize 192×192 rce_ic_logo.png rce_ic_logo.png

  cp rce_ic_logo.png ${rce_ic_logo_path_mip_hdpi}

  #convert -resize 192×192 rce_ic_logo.png rce_ic_logo.png

  cp rce_ic_logo.png ${rce_ic_logo_path_mip_mdpi}

  #convert -resize 192×192 rce_ic_logo.png rce_ic_logo.png

  cp rce_ic_logo.png ${rce_ic_logo_path_base_xh}

  #convert -resize 192×192 rce_ic_logo.png rce_ic_logo.png

  cp rce_ic_logo.png ${rce_ic_logo_path_image_xh}

fi

if [ -f “$notification_small_icon_file” ]; then

  notification_small_icon_path=”${WORKSPACE}/rcekit/src/main/res/drawable-xhdpi”

  #convert -resize 192×192 notification_small_icon.png notification_small_icon.png

  mv notification_small_icon.png ${notification_small_icon_path}

fi

if [ -f “$rce_ic_company_logo_file” ]; then

  rce_ic_company_logo_path=”${WORKSPACE}/rcekit/src/main/res/drawable-xxhdpi”

  mv rce_ic_company_logo.png ${rce_ic_company_logo_path}

fi

if [ -f “$rce_splash_bg_file” ]; then

  rce_splash_bg_path=”${WORKSPACE}/rcekit/src/main/res/drawable-xxhdpi”

  mv rce_splash_bg.png ${rce_splash_bg_path}

fi

3. After shell is executed, the generated APK cannot be sent to Tomcat for download

1) Install Tomcat, which will be installed here

2) I moved the generated APK directly to tomcat’s WebApp Download directory and then restarted Tomcat

Execution of the shell

cd ${WORKSPACE}/rce/build/outputs/apk/release/

Cp ${WORKSPACE} / rce/build/outputs/apk/release / *. Apk/usr/local/tomcat/apache tomcat — 9.0.22 / webapps/download

CD/usr/local/tomcat/apache tomcat – 9.0.22 / bin

./startup.sh

4. Archive operations

The end