Mobile Development 5 min read

Configuring Android Project Build, CI/CD Pipeline, and APK Upload with Jenkins and Python Scripts

This guide explains how to set up Android project packaging paths, write Python upload scripts for fir.im and Pgyer, configure a Jenkinsfile with checkout, build, and upload stages, and define Jenkins global variables and parameters for automated CI/CD of mobile apps.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
Configuring Android Project Build, CI/CD Pipeline, and APK Upload with Jenkins and Python Scripts

1. Project configuration: define the APK storage path under app/build/outputs/apk/[debug|release] and create upload scripts that support both fir.im and Pgyer platforms, referencing their API documentation and using a certificate retrieved from cert.binary .

The provided Python script uploadapk.py uses the requests library to obtain the upload certificate, then uploads the APK to the chosen platform (fir.im or Pgyer) with appropriate parameters such as key, token, app name, build ID, and version.

Usage example: python uploadapk.py demo-android-app-10 65d7edxxxxxxx7c4fabda25 app.apk demo-android-app 10 10.12 fir

2. Jenkinsfile: a simple pipeline with three stages—Checkout (retrieves the code), Build (executes Gradle commands), and Upload (renames the APK and runs the Python upload script). The Groovy script demonstrates how to invoke shell commands and capture the script output for display in the build description.

3. Jenkins configuration: add a global variable for the Android SDK, then create a pipeline job. Important parameters include buildShell (e.g., ./gradlew clean assembleDebug or ./gradlew clean assembleRelease ), bundleId , apiToken (from fir.im), apkVersion , and apkName .

4. Build and test process: the article illustrates the steps of checking out code, building the APK, and publishing it to both Fir and Pgyer platforms, showing screenshots of each stage and the resulting QR codes for download.

PythonCI/CDAndroidautomationAPKJenkinsupload
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.