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

-Prelease.versionIncrementer does not work as expected #591

Open
u6f6o opened this issue Mar 3, 2023 · 2 comments
Open

-Prelease.versionIncrementer does not work as expected #591

u6f6o opened this issue Mar 3, 2023 · 2 comments

Comments

@u6f6o
Copy link

u6f6o commented Mar 3, 2023

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

@bgalek
Copy link
Collaborator

bgalek commented Apr 4, 2023

hi! could you create a repo that i can debug? i.e. I'm missing out CI_COMMIT_BRANCH variable - is it set?

@finnlander
Copy link

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.

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

3 participants