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

Cannot get property 'value' on null object when using 'branchSpecific' incrementer #634

Open
finnlander opened this issue Jun 15, 2023 · 1 comment
Labels

Comments

@finnlander
Copy link

Hi,

First of all, thanks for the work you're doing for this great plugin.

To provide some context:

I've tried to accomplish a release flow where:

  • the new release starts with release-candidate versions (i.e. from "vX.Y.Z-alpha" -> "vX.Y.Z-rc1")
  • when the version has been well tested and accepted, the release tag is created from the latest release candidate (i.e. from "vX.Y.Z-rc1" -> "vX.Y.Z"

I didn't find any predefined solutions to accomplish such versioning, so I started looking at 'branchSpecificIncrementer'.

Used plugin version:

id("pl.allegro.tech.build.axion-release") version "1.15.3"

The issue:

For some weird reason, even though I have a "default" (or "catch all") type of matcher as a last entry:

 {... branch specific rules}
  '.*'       : { VersionIncrementerContext c ->
                return c.currentVersion.incrementPatchVersion()
            },

... running the markNextVersion task produces error:

Cannot get property 'value' on null object

I followed the stack trace to notice the error is coming from NPE on PredefinedVersionIncrementer.groovy (line 60):

    BRANCH_SPECIFIC('branchSpecific', { VersionIncrementerContext context, Map config ->
        def incrementer = config.find { context.scmPosition.branch ==~ it.key }
        return versionIncrementerFor(incrementer.value.toString(), config).apply(context)
    })

To be expected:

It would be much more helpful, if before applying incrementer.value.toString(), there would be a "null check" for the incrementer followed with proper error message stating:

"no matching branch specific incrementer was found for branch ${context.scmPosition.branch}"

(or something similar)

This would help understanding what is actually happening there.

I noticed the issue occurs more likely in case there is an existing version tag matching the current HEAD when running markNextVersion.

@bgalek
Copy link
Member

bgalek commented Jul 31, 2023

hi @finnlander!
Nice reaserch. Maybe you would like to contribute and add such an error msg/exception?

@bgalek bgalek added the bug label Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants