Skip to content

Instantly share code, notes, and snippets.

@juanlugm
Forked from tonespy/Jenkinsfile
Last active May 1, 2019 21:22
Show Gist options
  • Save juanlugm/ed7065b3887aaad727e18df5200c0101 to your computer and use it in GitHub Desktop.
Save juanlugm/ed7065b3887aaad727e18df5200c0101 to your computer and use it in GitHub Desktop.
Jenkins Pipeline Jenkinsfile
// Every jenkins file should start with either a Declarative or Scripted Pipeline entry point.
node {
// Global variable declaration
def project = 'project'
def appName = 'app'
// Stage, is to tell the Jenkins that this is the new process/step that needs to be executed
stage('Checkout') {
// Pull the code from the repo
checkout scm
}
stage('Build Image') {
// Build our docker Image
sh("docker build -t ${project} .")
}
stage('Run application test') {
// If you need environmental variables in your image. Why not load it attach it to the image, and delete it afterward
sh("env >> .env")
// Remove JAVA_HOME. Jenkins and Android dockers are not the same and it was overriding it.
sh("sed -i '/JAVA_HOME/d' .env")
sh("cat .env")
sh("docker run --env-file .env --rm ${project} ./gradlew test")
sh("rm -rf .env")
}
// stage('Deploy application') {
// // This is the cool part where you deploy. Here, you can specify builds you want to deploy
// switch (env.BRANCH_NAME) {
// case "master":
// sh("env >> .env")
// sh("sed -i '/JAVA_HOME/d' .env")
// sh("docker run --env-file .env --rm ${project} ./gradlew clean build assembleRelease crashlyticsUploadDistributionRelease")
// sh("rm -rf .env")
// break
// case "dev":
// sh("env >> .env")
// sh("sed -i '/JAVA_HOME/d' .env")
// sh("docker run --env-file .env --rm ${project} ./gradlew clean build assembleDebug crashlyticsUploadDistributionDebug")
// sh("rm -rf .env")
// break
// case "misuper":
// sh("env >> .env")
// sh("sed -i '/JAVA_HOME/d' .env")
// sh("docker run --env-file .env --rm ${project} ./gradlew clean build assembleDebug crashlyticsUploadDistributionDebug")
// sh("rm -rf .env")
// break
// }
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment