Skip to content

Instantly share code, notes, and snippets.

@JacquesSmuts
Last active December 26, 2018 08:12
Show Gist options
  • Save JacquesSmuts/217c77ec0e4d8ec8409ae45c3516ec07 to your computer and use it in GitHub Desktop.
Save JacquesSmuts/217c77ec0e4d8ec8409ae45c3516ec07 to your computer and use it in GitHub Desktop.
Deploying to track based on Git Branch
// Deployment
play {
track = getDeploymentTrack()
serviceAccountCredentials = file(System.getenv("PRIVATE_KEY") ?: "deployment_private_key.json")
defaultToAppBundles = true
resolutionStrategy = "ignore"
}
// The deployment track is based on the branch.
static def getDeploymentTrack() {
def branch = gitBranch()
def track = 'internal'
if (branch.equals("master")) {
track = "beta"
} else if (branch.equals("release")) {
track = "alpha"
}
println("DEPLOYMENT TRACK: " + track)
return track
}
static def gitBranch() {
def branch = ""
def proc = "git rev-parse --abbrev-ref HEAD".execute()
proc.in.eachLine { line -> branch = line }
proc.err.eachLine { line -> println line }
proc.waitFor()
println("BRANCH: " + branch)
branch
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment