Jenkins
Automated your tests in the Finalrun cloud with Jenkins
Prerequisites
Before setting up Jenkins integration, ensure you have:
Jenkins Server - Running locally or on dedicated server
FinalRun API Key - Obtain from your FinalRun dashboard
App tag - Obtain from your FinalRun dashboard in Apps Section for the specific app
Git Repository - Accessible by Jenkins
Add Finalrun API key to Secrets
Navigate to Manage Jenkins → Manage Credentials
Click (global) domain → Add Credentials
Configure:
Kind: Secret text
Scope: Global
Secret: Your FinalRun API key
ID:
finalrun-api-key
Description: FinalRun API Key for CI/CD
Jenkinsfile Configuration
Create a Jenkinsfile
in your repository root:
pipeline {
agent any
environment {
FINALRUN_API_KEY = credentials('finalrun-api-key')
APP_TAG = 'cicd_sample_android'
}
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 in the cloud..."
export PATH="$HOME/.finalrun/bin:$PATH"
finalrun-cli execute \\
--api-key="${FINALRUN_API_KEY}" \\
--app="${APP_TAG}=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()
}
}
}
Last updated