@@ -10,19 +10,35 @@ val buildNumber = providers.environmentVariable("GITHUB_RUN_NUMBER").orNull
1010val isRelease = providers.environmentVariable(" GITHUB_EVENT_NAME" ).orNull == " release"
1111
1212if (buildNumber != null && ! isRelease) {
13- val offset = try {
14- val description = providers.exec {
13+ var offset = " 0"
14+
15+ try {
16+ val describeResult = providers.exec {
1517 commandLine(" git" , " describe" , " --tags" , " --long" )
16- }.standardOutput.asText.get().trim()
17- val parts = description.split(" -" )
18- if (parts.size >= 3 ) parts[parts.size - 2 ] else " 0"
18+ isIgnoreExitValue = true
19+ }
20+ val exitCode = describeResult.result.get().exitValue
21+
22+ if (exitCode == 0 ) {
23+ val description = describeResult.standardOutput.asText.get().trim()
24+ val parts = description.split(" -" )
25+ if (parts.size >= 3 ) {
26+ offset = parts[parts.size - 2 ]
27+ }
28+ }
1929 } catch (e: Exception ) {
30+ }
31+
32+ if (offset == " 0" ) {
2033 try {
21- providers.exec {
34+ val revListResult = providers.exec {
2235 commandLine(" git" , " rev-list" , " --count" , " HEAD" )
23- }.standardOutput.asText.get().trim()
36+ isIgnoreExitValue = true
37+ }
38+ if (revListResult.result.get().exitValue == 0 ) {
39+ offset = revListResult.standardOutput.asText.get().trim()
40+ }
2441 } catch (e: Exception ) {
25- " 0"
2642 }
2743 }
2844
@@ -32,6 +48,7 @@ if (buildNumber != null && !isRelease) {
3248
3349val changelogText = providers.environmentVariable(" CHANGELOG" ).orElse(providers.exec {
3450 commandLine(" git" , " log" , " -1" , " --format=%B" )
51+ isIgnoreExitValue = true
3552}.standardOutput.asText)
3653
3754logger.lifecycle(" Building version: $version " )
0 commit comments