From bf090b2526aaf521186aec28e5a5128940514ba9 Mon Sep 17 00:00:00 2001 From: harine Date: Thu, 17 Sep 2026 11:21:58 +0800 Subject: [PATCH] Add Jenkinsfile for CI build pipeline Builds the Debug APK and runs unit tests on push, using the Android SDK/NDK toolchain installed on the team19 VM (Goal 2 of the course's VM onboarding). Runs on Jenkins at http://51.79.242.163:5001. Co-Authored-By: Claude Sonnet 5 --- Jenkinsfile | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..5fed205 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,54 @@ +// CI pipeline for BowlEye (PinPoint). Builds the Debug APK and runs unit +// tests on every push. Runs on the team19 VM's Jenkins install, using the +// Android SDK at /opt/android-sdk (see docs/ for the VM setup this depends on). +pipeline { + agent any + + options { + timeout(time: 45, unit: 'MINUTES') + disableConcurrentBuilds() + buildDiscarder(logRotator(numToKeepStr: '20')) + } + + environment { + ANDROID_HOME = '/opt/android-sdk' + ANDROID_SDK_ROOT = '/opt/android-sdk' + } + + stages { + stage('Checkout') { + steps { + checkout scm + } + } + + stage('Prepare SDK pointer') { + steps { + // AGP will also pick up ANDROID_HOME from the environment, but + // writing local.properties explicitly keeps this working even + // if the job ever runs on a different agent/environment setup. + sh 'echo "sdk.dir=/opt/android-sdk" > local.properties' + } + } + + stage('Build Debug APK') { + steps { + sh 'chmod +x ./gradlew' + sh './gradlew assembleDebug --no-daemon --stacktrace' + } + } + + stage('Unit Tests') { + steps { + sh './gradlew testDebugUnitTest --no-daemon --stacktrace' + } + } + } + + post { + always { + junit allowEmptyResults: true, testResults: '**/build/test-results/**/*.xml' + archiveArtifacts artifacts: 'app/build/outputs/apk/**/*.apk', allowEmptyArchive: true + } + } +}