axion-release-plugin
axion-release-plugin copied to clipboard
-Prelease.versionIncrementer does not work as expected
Hi,
I am struggling a bit with the creation of pre-release version with axion on gitlab. The idea is to allow to create pre-release versions from branches and thus I added the following to my gitlab-ci.yml:
release.candidate.minor:
extends: .gradle_job
stage: publish
only:
- branches
when: manual
script:
- git remote set-url origin ${CI_SERVER_URL}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}.git
- ./gradlew release -Prelease.versionIncrementer=incrementPrerelease -Prelease.disableChecks -Prelease.pushTagsOnly -Prelease.overriddenBranchName=${CI_COMMIT_BRANCH} -Prelease.customUsername=${GRGIT_USER} -Prelease.customPassword=${GRGIT_PASS}
The build.gradle.kts file looks like the following:
plugins {
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
`maven-publish`
id("pl.allegro.tech.build.axion-release") version "1.14.4"
}
repositories {
mavenCentral()
}
scmVersion {
versionIncrementer("incrementPrerelease", mapOf("initialPreReleaseIfNotOnPrerelease" to "rc1"))
}
group = "com.acme"
version = scmVersion.version
dependencies {
testImplementation(gradleTestKit())
testImplementation(platform("org.junit:junit-bom:5.9.2"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("io.kotlintest:kotlintest-runner-junit5:3.4.2")
}
tasks.test {
useJUnitPlatform()
}
When I execute this gitlab task though, the job increments the patch version instead of adding a -rc1 suffix to the version:
$ export GRADLE_USER_HOME=`pwd`/.gradle
$ git remote set-url origin ${CI_SERVER_URL}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}.git
$ ./gradlew release -Prelease.versionIncrementer=incrementPrerelease -Prelease.disableChecks -Prelease.pushTagsOnly -Prelease.overriddenBranchName=${CI_COMMIT_BRANCH} -Prelease.customUsername=${GRGIT_USER} -Prelease.customPassword=${GRGIT_PASS}
Welcome to Gradle 7.6!
Here are the highlights of this release:
- Added support for Java 19.
- Introduced `--rerun` flag for individual task rerun.
- Improved dependency block for test suites to be strongly typed.
- Added a pluggable system for Java toolchains provisioning.
For more details see https://docs.gradle.org/7.6/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :verifyRelease
Skipping uncommitted changes check
Skipping ahead of remote check
Skipping snapshot dependencies check
> Task :release
Creating tag: v1.1.2
Pushing all to remote: origin
BUILD SUCCESSFUL in 12s
2 actionable tasks: 2 executed
hi! could you create a repo that i can debug? i.e. I'm missing out CI_COMMIT_BRANCH variable - is it set?
Is the problem here that the versionIncrementer(...) in build.gradle.kts defines the default version policy, but when using -Prelease.versionIncrementer=incrementPrerelease CLI flag, it overrides the default policy (that had the parameter map included) and therefore, it does not include that initialPreReleaseIfNotOnPrerelease definition?
I've been wondering it too that how to pass that option via the command line in CI setup.
Help on that would be much appreciated.