Skip to content

Instantly share code, notes, and snippets.

@FyberEngineers
Created March 5, 2020 09:22
Show Gist options
  • Save FyberEngineers/e8a02d4ebdd914ae8964d0b39c0eb1a6 to your computer and use it in GitHub Desktop.
Save FyberEngineers/e8a02d4ebdd914ae8964d0b39c0eb1a6 to your computer and use it in GitHub Desktop.
def pom = readFile 'pom.xml'
def project = new XmlSlurper().parseText(pom)
String version = project.version.toString()
String tarName = "volcano-${version}-release-pack.tar.gz"
stage('Release'){
@NonCPS
def newVersion = {
def doesFileExist = fileExists 'releases.txt'
if (doesFileExist) {
echo "file releases.txt exists"
def file = readFile 'releases.txt'
String fileContents = file.toString()
Integer newTarVersion = fileContents.toInteger() + 1
writeFile file: 'releases.txt', text: newTarVersion.toString()
echo "new tar version is: " + newTarVersion
} else {
echo "file releases.txt does not exist"
writeFile file: 'releases.txt', text: "1"
}
readFile 'releases.txt'
}
if (branch.startsWith("release") || branch.startsWith("hotfix")) {
String tarRCVersion = newVersion()
newTarName = "volcano${version}-RC-${tarRCVersion}-release-pack.tar.gz"
sh "mv ./volcano/target/${tarName} ./viper/target/${newTarName}"
tarName = newTarName
}
step('Commit and push releases file') {
sh "git remote set-url origin git@bitbucket.org:fullgc/volcano.git"
sh "git add -A"
sh "git commit -m 'update volcano version to '${tarRCVersion}"
sh "git push"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment