Add support for setting build version using env variable
This commit is contained in:
18
build.gradle
18
build.gradle
@@ -41,17 +41,25 @@ def debBuildDataPath = "${debBuildBasePath}${debDataPath}"
|
|||||||
def debBuildSystemdPath = "${debBuildBasePath}${debSystemdPath}"
|
def debBuildSystemdPath = "${debBuildBasePath}${debSystemdPath}"
|
||||||
|
|
||||||
def dockerImageName = "kamax/mxisd"
|
def dockerImageName = "kamax/mxisd"
|
||||||
def dockerImageTag = "${dockerImageName}:${gitVersion()}"
|
def dockerImageTag = "${dockerImageName}:${mxisdVersion()}"
|
||||||
|
|
||||||
|
String mxisdVersion() {
|
||||||
|
def versionPattern = Pattern.compile("v(\\d+\\.)?(\\d+\\.)?(\\d+)(-.*)?")
|
||||||
|
|
||||||
|
String version = System.getenv('MXISD_BUILD_VERSION')
|
||||||
|
if (version == null || version.size() == 0) {
|
||||||
|
version = gitVersion()
|
||||||
|
}
|
||||||
|
return versionPattern.matcher(version).matches() ? version.substring(1) : version
|
||||||
|
}
|
||||||
|
|
||||||
String gitVersion() {
|
String gitVersion() {
|
||||||
def versionPattern = Pattern.compile("v(\\d+\\.)?(\\d+\\.)?(\\d+)(-.*)?")
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream()
|
ByteArrayOutputStream out = new ByteArrayOutputStream()
|
||||||
exec {
|
exec {
|
||||||
commandLine = ['git', 'describe', '--tags', '--always', '--dirty']
|
commandLine = ['git', 'describe', '--tags', '--always', '--dirty']
|
||||||
standardOutput = out
|
standardOutput = out
|
||||||
}
|
}
|
||||||
def v = out.toString().replace(System.lineSeparator(), '')
|
return out.toString().replace(System.lineSeparator(), '');
|
||||||
return versionPattern.matcher(v).matches() ? v.substring(1) : v
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
@@ -154,7 +162,7 @@ processResources {
|
|||||||
|
|
||||||
task buildDeb(dependsOn: build) {
|
task buildDeb(dependsOn: build) {
|
||||||
doLast {
|
doLast {
|
||||||
def v = gitVersion()
|
def v = mxisdVersion()
|
||||||
println "Version for package: ${v}"
|
println "Version for package: ${v}"
|
||||||
mkdir distDir
|
mkdir distDir
|
||||||
mkdir debBuildBasePath
|
mkdir debBuildBasePath
|
||||||
|
|||||||
Reference in New Issue
Block a user