Skip to content

Instantly share code, notes, and snippets.

@FyberEngineers
Created March 5, 2020 09:23
Show Gist options
  • Save FyberEngineers/c96729dc7ae6356b7185576d67279b74 to your computer and use it in GitHub Desktop.
Save FyberEngineers/c96729dc7ae6356b7185576d67279b74 to your computer and use it in GitHub Desktop.
if (!branch.startsWith('ST-')){
stage('Deploy') {
def incrementVersion = {
def environment = {
switch(branch) {
case 'develop': 'development.json'
break
case 'master': 'production.json'
break
default: 'qa.json'
}
}
def environmentFileContent = readFile environment
def environmentJson = new groovy.json.JsonSlurper().parseText(environmentFileContent)
environmentJson.default_attributes.volcano.version = "volcano-${version}"
String environmentPrettyJsonString = new groovy.json.JsonBuilder(environmentJson).toPrettyString()
environmentJson = null
writeFile file: $environment, text: environmentPrettyJsonString
sh "git commit -am 'Changed volcano version in $environment env to '${version}"
sh "git push"
}
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', browser: [$class: 'BitbucketWeb', repoUrl: 'https://bitbucket.org/fullgc/chef'], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch:
'**']], submoduleCfg: [], userRemoteConfigs: [[url: 'git@bitbucket.org:fullgc/chef']]]
dir('environments/') {
incrementVersion()
}
slackSend channel: 'server', color: 'good', message: " New volcano version ${version} is being deployed to $environment"
}
if (branch == 'develop' || branch == 'master') sh "rm releases.txt"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment