Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default Versioncreator "VERSION_WITH_BRANCH" changes Release-Version name #789

Closed
sforberger opened this issue Aug 5, 2024 · 11 comments
Closed

Comments

@sforberger
Copy link

sforberger commented Aug 5, 2024

I am not sure if my problem is a bug.

With Version 1.18.0 the default versionCreator changes from simple to VERSION_WITH_BRANCH.

gradle currentVersion on mainbranch is still 1.2.0-SNAPSHOT

Gradle release creates the Tag v1.2.0.
But the gitlab-ci pipeline running on the tagged version, publishs Version 1.2.0-v1.2.0 to maven repository.

It looks like the decorate step is now also being executed for a release

With
scmVersion { versionCreator("simple") }
it works as expected.

@bgalek
Copy link
Member

bgalek commented Aug 5, 2024

hi!
Can you make sure that on gitlab-ci you checkout on branch not tag? it seems like 1.2.0-v1.2.0 is just {version}-{tag}

@sforberger
Copy link
Author

Hi,
git strategy is set to git fetch.
I am using Axion to create the Release-Tag.

@bgalek
Copy link
Member

bgalek commented Aug 5, 2024

could you add "git status" command before release step and show me your build output?

@sforberger
Copy link
Author

sforberger commented Aug 5, 2024

$ git status
HEAD detached at 94bcecc
nothing to commit, working tree clean
$ gradle currentVersion
To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.9/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
Daemon will be stopped at the end of the build 
> Task :buildSrc:checkKotlinGradlePluginConfigurationErrors
> Task :buildSrc:generateExternalPluginSpecBuilders UP-TO-DATE
> Task :buildSrc:extractPrecompiledScriptPluginPlugins UP-TO-DATE
> Task :buildSrc:compilePluginsBlocks UP-TO-DATE
> Task :buildSrc:generatePrecompiledScriptPluginAccessors UP-TO-DATE
> Task :buildSrc:generateScriptPluginAdapters UP-TO-DATE
> Task :buildSrc:compileKotlin UP-TO-DATE
> Task :buildSrc:compileJava NO-SOURCE
> Task :buildSrc:compileGroovy NO-SOURCE
> Task :buildSrc:pluginDescriptors UP-TO-DATE
> Task :buildSrc:processResources UP-TO-DATE
> Task :buildSrc:classes UP-TO-DATE
> Task :buildSrc:jar UP-TO-DATE
> Task :conventions-plugin:currentVersion
Project version: 1.20.0-v1.20.0

@bgalek
Copy link
Member

bgalek commented Aug 5, 2024

I see HEAD detached at 94bcecc

So as stated in docs:

Since Gitlab will do a detached head checkout, the branch name has to be overridden when versionWithBranch is used.

So just add -Prelease.overriddenBranchName=${CI_COMMIT_REF_SLUG} to your release step and you'll be ready to go ;)

First class gitlab support PR would be appreciated!
So users won't need to add this ;)

You can check @radoslaw-panuszewski PR as inspiration #776

@sforberger
Copy link
Author

I have the overridden branch name in the local gradle.properties

echo "release.overriddenBranchName=$CI_COMMIT_REF_NAME" >> $GRADLE_USER_HOME/gradle.properties

CI_COMMIT_REF_NAME='v1.20.0'

@bgalek
Copy link
Member

bgalek commented Aug 5, 2024

if CI_COMMIT_REF_NAME='v1.20.0' than the version resolved will be 1.2.0-v1.2.0
if CI_COMMIT_REF_NAME will be master or main this version won't be suffixed with branchname

@sforberger
Copy link
Author

I switched to CI_COMMIT_REF_SLUG and it's still the same.

@bgalek
Copy link
Member

bgalek commented Aug 5, 2024

maybe you could share your whole pipeline file?

@sforberger
Copy link
Author

cipipeline.txt
Ci-Pipeline Definition as File

@bgalek
Copy link
Member

bgalek commented Aug 6, 2024

I've tested gitlab-ci integration, and it works fine, I recommend using the release command just like in the docs or this repo:
https://gitlab.com/bgalek/axion-test/-/blob/master/.gitlab-ci.yml?ref_type=heads
https://gitlab.com/bgalek/axion-test/-/jobs/7512709274
https://gitlab.com/bgalek/axion-test/-/tags
(ofc you need to adjust it for your needs)

@bgalek bgalek closed this as completed Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants