Skip to content
Snippets Groups Projects
Commit 24e1cac9 authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

use try catch

parent e1c1046e
No related branches found
No related tags found
2 merge requests!619Production Release | nshmp-haz,!614Try Catch Version
......@@ -2,23 +2,27 @@ apply plugin: "com.palantir.git-version"
tasks.withType(JavaCompile) {
doFirst {
def versionFile = new File("${projectDir}/src/main/resources/version/nshmp-haz-version.json")
new File(versionFile.getParent()).mkdirs()
def details = versionDetails()
def ciProjectUrl = System.getenv("CI_PROJECT_URL")
def branch = System.getenv("CI_COMMIT_BRANCH")
def versionInfo = [
branchName: branch ? branch : details.branchName,
commitDistance: details.commitDistance,
gitHash: details.gitHash,
gitHashFull: details.gitHashFull,
isCleanTag: details.isCleanTag,
lastTag: details.lastTag,
projectName: project.name,
url: ciProjectUrl ? ciProjectUrl : 'git config --get remote.origin.url'.execute().text.replace('\n', ''),
version: details.version,
]
def json = groovy.json.JsonOutput.toJson(versionInfo)
versionFile.write(groovy.json.JsonOutput.prettyPrint(json))
try {
def versionFile = new File("${projectDir}/src/main/resources/version/nshmp-haz-version.json")
new File(versionFile.getParent()).mkdirs()
def details = versionDetails()
def ciProjectUrl = System.getenv("CI_PROJECT_URL")
def branch = System.getenv("CI_COMMIT_BRANCH")
def versionInfo = [
branchName: branch ? branch : details.branchName,
commitDistance: details.commitDistance,
gitHash: details.gitHash,
gitHashFull: details.gitHashFull,
isCleanTag: details.isCleanTag,
lastTag: details.lastTag,
projectName: project.name,
url: ciProjectUrl ? ciProjectUrl : "git config --get remote.origin.url".execute().text.replace("\n", ""),
version: details.version,
]
def json = groovy.json.JsonOutput.toJson(versionInfo)
versionFile.write(groovy.json.JsonOutput.prettyPrint(json))
} catch (Exception e) {
println("Failed to create version file.")
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment