Jenkins
Automated your tests in the Finalrun cloud with Jenkins
Last updated
Automated your tests in the Finalrun cloud with Jenkins
Last updated
pipeline {
agent any
environment {
FINALRUN_API_KEY = credentials('finalrun-api-key')
// Use the exact app name as it appears in your FinalRun dashboard
APP_NAME = 'My Android App'
}
stages {
stage('Checkout') {
steps {
checkout scm
script {
env.GIT_COMMIT_SHORT = sh(
script: "git rev-parse --short HEAD",
returnStdout: true
).trim()
}
}
}
stage('Build APK') {
steps {
script {
sh '''
echo "Building Android APK..."
export PATH=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${ANDROID_SDK_ROOT}/platform-tools:$PATH
# Grant execute permission to gradlew
chmod +x gradlew
# Build APK (Debug)
./gradlew assembleDebug
# Verify APK was created
ls -la app/build/outputs/apk/debug/
'''
}
}
}
stage('Install FinalRun CLI') {
steps {
script {
sh '''
echo "Installing FinalRun CLI..."
rm -rf ~/.finalrun/bin/finalrun-cli
curl -Ls "https://get-cli.finalrun.app/install.sh" | bash
export PATH="$HOME/.finalrun/bin:$PATH"
# Verify installation
which finalrun-cli
finalrun-cli --version
finalrun-cli --help
'''
}
}
}
stage('Run FinalRun Tests') {
steps {
script {
sh '''
echo "Running FinalRun tests..."
export PATH="$HOME/.finalrun/bin:$PATH"
finalrun-cli execute \\
--api-key="${FINALRUN_API_KEY}" \\
--app="${APP_NAME}=app/build/outputs/apk/debug/app-debug.apk" \\
--description="Jenkins CI/CD - Build: ${BUILD_NUMBER}, Commit: ${GIT_COMMIT_SHORT}"
'''
}
}
}
}
post {
success {
echo "✅ Pipeline completed successfully!"
}
failure {
echo "❌ Pipeline failed!"
}
cleanup {
cleanWs()
}
}
}