Abstract

This paper introduces the process of Jenkins configuration on the Mac system, and then a new project to integrate Walle and AndResGuard, and continuous integration of Android projects hosted on Git. Walle is a new generation of channel package packaging artifact under the Signature of Meituan’s open source Android Signature V2 Scheme. AndResGuard is an open source source file obfuscation tool for wechat. The overall process of my integration is as follows: Configure the Jenkins integration environment, use Jenkins gradle plug-in to type unsigned packages, and then use jar packages provided by AndResGuard to confuse resource files and get the confused unsigned packages (AndResGuard does not support V2 signature at present, Only v1 signature), and then use the Apksigner tool provided by Android SDK to sign the package V2. Finally, use the JAR package provided by Walle to write channel information to the Apk file and output channel package.

Configure the Jenkins integration environment

Because this article is not mainly about how to configure the Jenkins integration environment, and there are many tutorials online. I personally don’t have any major problems with the configuration process on the Mac, and it may be slightly different on Windows.

  • Pre-install Java and Git, and configure the local environment variables;
  • To install Homebrew, enter the commandbrew install jenkinsJenkins installation;
  • Enter your password, go into Jenkins, install the plugins, many of them are already installed, installEnvironment InjectorWe have to do is
  • Configure ANDROID_HOME in Administration – System Settings

  • Configure the Jdk in System Administration – Global Tools Configuration
  • Configure Gradle in system Administration – Global Tools configuration. You can install Gradle automatically for Jenkins or you can choose local as long as the version number is the same as that of the project. You can also configure environment variables for the Gadle command on the local computer.

Creating an Android project

Create a new project in Android Studio, integrate with Walle, and simply output the channel information:

        String channel = WalleChannelReader.getChannel(this.getApplicationContext());
        TextView textView=findViewById(R.id.text);
        textView.setText("channel=="+channel);
Copy the code

Then upload it to Github. Create a new free style software project in Jenkins and click parameterized build:


The output is as follows: open any Apk file and see that the resource file has been confused.

V2 signature (add SDK /build-tools path to local global variables) :

Java-jar apksigner.jar sign --ks key. JKS --ks-key-alias releasekey --ks-pass pass:pp123456 --key-pass pass:pp123456 --out output.apk input.apkCopy the code

Enter the list of channel packages entered into the markets.txt file:

cd ${WORKSPACE}
if[[!-d "${SOURCE_TARGET}"]].then
  git clone ${PROJECT_GIT_REPO} ${WORKSPACE} -b ${PROJECT_GIT_BRANCH}
fi
cd ${WORKSPACE}

git pull --no-commit --all

echo "Latest Submission :"$(git log -p -1 --pretty=format:"%s (%an)" --name-only | grep ")")

APP_VERSION=$(
path=${WORKSPACE}/build.gradle
key="versionName"
loop=1
version=""
while read line
do
     readText=${line%%%=*}
    if [[ $readText= ~$key ]]
     then
          version=${readText:15:5}
          break
     fi
     ((loop++))
done < $path
echo $version
)
echo APP_VERSION=$APP_VERSION > ${WORKSPACE}/build.properties

echo $Markets
if [ "$Markets"! ="" ]; then 
   rm -f markets.txt

   arr=$(echo $Markets|tr "," "\n")
   for x in $arr; do
    echo $x >> markets.txt
  done
fi
Copy the code

Finally, call Walle jar package for multi-channel packaging

build

Select Build with Parameters and enter the channel list each time you Build:

Afterword.

According to the developers, the next version of AndResGuard will support V2 signatures, see — link, and the process will be much simpler.

Add: the Develop branch has added v2 signature functionality since March 1, see Provide the latest JAR file for V2 signature

You can do away with parameterized builds and written shell commands and write the channel list directly to markets.txt. But I do this to facilitate the operation of the students pack.

For more implementation details, please visit the project’s github address –github.com/renjianan/J…