axion-release-plugin icon indicating copy to clipboard operation
axion-release-plugin copied to clipboard

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

Open finnlander opened this issue 2 years ago • 1 comments

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.

finnlander avatar Jun 15 '23 11:06 finnlander

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

bgalek avatar Jul 31 '23 21:07 bgalek