pipeline { agent any environment { ANDROID_HOME = "${env.HOME}/android-sdk" // Chemin confirmé par votre capture d'écran JAVA_HOME = "/usr/lib/jvm/java-17-openjdk-amd64" // ✅ On écrit le chemin complet ici aussi pour être 100% sûr PATH = "/usr/lib/jvm/java-17-openjdk-amd64/bin:/usr/local/bin:/opt/flutter/bin:${env.HOME}/android-sdk/cmdline-tools/latest/bin:${env.HOME}/android-sdk/platform-tools:${env.PATH}" STORE_PASS = credentials('android-store-pass') KEY_PASS = credentials('android-key-pass') } stages { stage('Checkout') { steps { // Récupère le code depuis Gitea checkout scm } } stage('Setup Dependencies') { steps { sh 'flutter config --no-analytics' sh 'flutter pub get' } } stage('Build & Deploy Android') { steps { withCredentials([ file(credentialsId: 'android-keystore-file', variable: 'KEYSTORE_PATH'), file(credentialsId: 'google-play-json', variable: 'GOOGLE_JSON'), // 1. On récupère le fichier .env stocké dans Jenkins file(credentialsId: 'flutter-env-file', variable: 'ENV_FILE_REF') ]) { script { // 2. On copie le fichier secret vers la racine du workspace sous le nom ".env" sh 'cp $ENV_FILE_REF .env' // ... Votre code existant pour key.properties ... sh """ echo storePassword=$STORE_PASS > android/key.properties echo keyPassword=$KEY_PASS >> android/key.properties echo keyAlias=upload >> android/key.properties echo storeFile=$KEYSTORE_PATH >> android/key.properties """ // ... Lancer Fastlane ... dir('android') { sh "GOOGLE_JSON_KEY_PATH='$GOOGLE_JSON' fastlane deploy_internal" } } } } } post { always { // Sécurité : On supprime le fichier contenant les mots de passe sh 'rm -f android/key.properties' } } }