Skip to content

Commit a76e915

Browse files
authored
Merge pull request #2 from innogames/git_current_version
Fix problem with calculated version from tag
2 parents 7050383 + 5019b9c commit a76e915

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

vars/gitSteps.groovy

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,15 @@ def call(Map config) {
8383
env['NEW_VERSION'] = Version(params.UPDATE_VERSION, versionParts)
8484
}
8585

86+
// Set GIT_CURRENT_VERSION to a tag name without leading 'v' with fallback to GIT_LAST_VERSION
87+
if (env['GIT_BRANCH_OR_TAG'] == 'tag' && env['GIT_LOCAL_BRANCH'] =~ /^v(\d+\.)+\d+$/) {
88+
env['GIT_CURRENT_VERSION'] = env['GIT_LOCAL_BRANCH'].replaceFirst(~/^v/,'')
89+
} else {
90+
env['GIT_CURRENT_VERSION'] = env['GIT_LAST_VERSION']
91+
}
92+
8693
env['GIT_NEW_TAG'] = "v${env['NEW_VERSION']}"
87-
env['TARGET_VERSION'] = env['GIT_BRANCH_OR_TAG'] == 'branch' ? env['NEW_VERSION'] : env['GIT_LAST_VERSION']
94+
env['TARGET_VERSION'] = env['GIT_BRANCH_OR_TAG'] == 'branch' ? env['NEW_VERSION'] : env['GIT_CURRENT_VERSION']
8895

8996
// We change build display name by default
9097
if (config.get('changeBuildName', true)) {

0 commit comments

Comments
 (0)