Skip to content

Instantly share code, notes, and snippets.

@PrashantBhatasana
Last active August 26, 2021 15:35
Show Gist options
  • Save PrashantBhatasana/e7d31c681d518d50dbc4699a4d695b0a to your computer and use it in GitHub Desktop.
Save PrashantBhatasana/e7d31c681d518d50dbc4699a4d695b0a to your computer and use it in GitHub Desktop.
This is the Jenkins file for building React Navite application.
def err = null
try {
node {
stage('Preparation') {
git credentialsId: 'fef4159e-285b-45d9-80ca-5981c4576ba5', url: 'https://github.com/prashant-bhatasana/demoApp/'
}
stage('Dependencies') {
sh 'sudo npm install -g react-native-cli'
sh 'npm install'
sh 'react-native link'
sh 'export JAVA_HOME=/opt/jdk1.8.0_201'
sh 'export JRE_HOME=/opt/jdk1.8.0_201/jre'
sh 'export PATH=$PATH:/opt/jdk1.8.0_201/bin:/opt/jdk1.8.0_201/jre/bin'
sh 'echo $JAVA_HOME'
}
stage('Clean Build') {
dir("android") {
sh "pwd"
sh 'ls -al'
sh './gradlew clean'
}
}
stage('Build release ') {
parameters {
credentials credentialType: 'org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl', defaultValue: '5d34f6f7-b641-4785-frd5-c93b67e71b6b', description: '', name: 'keystore', required: true
}
dir("android") {
sh './gradlew assembleRelease'
}
}
stage('Compile') {
archiveArtifacts artifacts: '**/*.apk', fingerprint: true, onlyIfSuccessful: true
}
}
} catch (caughtError) {
err = caughtError
currentBuild.result = "FAILURE"
} finally {
if(currentBuild.result == "FAILURE"){
sh "echo 'Build FAILURE'"
}else{
sh "echo 'Build SUCCESSFUL'"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment