Created
November 12, 2019 18:46
-
-
Save topriddy/80f29fadc4c098b4b349ee565cabbc51 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'org.ajoberstar.grgit' | |
task doVersioning() { | |
if (version == '') { | |
def timestamp = new Date().format("yyyyMMddHHmmss") | |
def githash = "${grgit.head().abbreviatedId}" | |
def currentBranchName = branch ?: grgit.branch.current().name | |
def shortBranchName = ["feature", "experiment", "spike", "bugfix", "hotfix"].find { | |
currentBranchName.startsWith(it) | |
} | |
if (currentBranchName == "master") shortBranchName = "master" | |
if (currentBranchName == "develop") shortBranchName = "develop" | |
if (shortBranchName == null) shortBranchName = "feature" | |
version = "${shortBranchName}-${githash}-${timestamp}" | |
shortVersion = "${githash}-${timestamp}" | |
new File("$projectDir/project-name.properties").text = "dockerTag=${version}" + "\n" + "shortVersion=${shortVersion}"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment