This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent { | |
// Run on a build agent where we have the Android and iOS are configured | |
label 'reactNative' | |
} | |
environment { | |
CI = 'true' | |
} | |
stages { | |
stage('Checkout') { | |
steps { | |
git 'https://github.com/awesome-reactNative-app' | |
} | |
} | |
stage('Build and Test') { | |
steps { | |
sh 'npm install && npm test' | |
} | |
} | |
// Automating the Android build, test and deploy | |
stage('Configure Google Service Account') { | |
steps { | |
withCredentials([file(credentialsId: 'Firebase Service Account', variable: 'google-service.json')]) { | |
sh 'copy "%GOOGLE_SERVICES_SRC%" "google-services.json"' | |
} | |
} | |
} | |
stage('Release Android App') { | |
steps { | |
withCredentials([file(credentialsId: 'Firebase Service Account', variable: 'google-service.json')]) { | |
sh 'cd android && ./gradlew assembleRelease && cd ..' | |
} | |
} | |
} | |
stage('Sign Android App') { | |
steps{ | |
signAndroidApks ( | |
keyStoreId: "certificate", | |
keyAlias: "key0", | |
apksToSign: "android/app/build/outputs/apk/app-release.apk" | |
) | |
} | |
} | |
stage('Run Androis UI tests with Detox') { | |
steps { | |
sh('detox build -c android && detox test -c android') | |
} | |
} | |
stage('Authenticate Google Cloud Project') { | |
steps { | |
withCredentials([file(credentialsId: 'Firebase Service Account', variable: 'google-service.json')]) { | |
sh 'gcloud auth activate-service-account --key-file "%GOOGLE_CLOUD_SERVICE_ACCOUNT_KEY%"' | |
} | |
} | |
} | |
stage('Config Google CLoud Project') { | |
steps { | |
withCredentials([file(credentialsId: 'Firebase Service Account', variable: 'google-service.json')]) { | |
sh 'gcloud config set project reactnative-demo' | |
} | |
} | |
} | |
stage('Upload Android Beta App to Firebase App Distribution') { | |
steps { | |
withCredentials([file(credentialsId: 'Firebase Service Account', variable: 'google-service.json')]) { | |
sh 'firebase appdistribution:distribute android/app/build/outputs/apk/app-release.apk --app [FIREBASE_APP_ID] --release-notes "Bug fixes and improvements" --testers "comma seperated email"' | |
} | |
} | |
} | |
stage('Upload Android App to Goole Play Store') { | |
androidApkUpload googleCredentialsId: 'Google Play Key', apkFilesPattern: '**/*-release.apk', trackName: 'production' | |
} | |
// Automating the iOS build, test and deploy | |
stage('Install iOS dependencies'){ | |
steps{ | |
sh 'bundle exec pod install' | |
} | |
} | |
stage('Fetch dev Certificates'){ | |
steps{ | |
sh 'bundle exec fastlane fetch_dev_certificates' | |
} | |
} | |
stage('Fetch Distribution Certificates'){ | |
steps{ | |
sh 'bundle exec fastlane fetch_distribution_certificates' | |
} | |
} | |
stage('Run iOS UI tests with Detox') { | |
steps { | |
sh('detox build -c ios && detox test -c ios') | |
} | |
} | |
stage('Release build to TestFlight'){ | |
steps{ | |
sh 'bundle exec fastlane release' | |
} | |
} | |
stage('Release the app to App Store'){ | |
steps{ | |
sh 'bundle exec fastlane release_applestore' | |
} | |
} | |
post { | |
success { | |
slackSend channel: '#automation', message: 'The $BUILD_NUMBER succeeded and the apps uploaded successfully' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment