axion-release-plugin
axion-release-plugin copied to clipboard
Lightweight tags matching to version pattern cause NullPointerException
Hi,
We tried to add axion-release-plugin to existing project but we encountered following problem:
- What went wrong: (plain error message without --debug --stacktrace)
Execution failed for task ':release'. Cannot get property 'name' on null object
- Stacktrace:
Caused by: java.lang.NullPointerException: Cannot get property 'name' on null object
at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository$_tag_closure1.doCall(GitRepository.groovy:71)
at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.tag(GitRepository.groovy:70)
- Affected versions
1.10.2 1.10.3
- Code
boolean isOnExistingTag = jgitRepository.tagList().call().any({
it -> it.name == GIT_TAG_PREFIX + tagName && jgitRepository.repository.peel(it).peeledObjectId.name == headId
})
After some checks I found that in our repository we already have few lightweight tags that match to version pattern used by the plugin:
git for-each-ref refs/tags
... commit refs/tags/release-0.4.10
... commit refs/tags/release-0.4.11
... commit refs/tags/release-0.4.12
... commit refs/tags/release-0.4.13
... commit refs/tags/release-0.4.14
... tag refs/tags/release-0.4.15
... commit refs/tags/release-0.4.5
... tag refs/tags/release-0.4.6
... commit refs/tags/release-0.4.7
... commit refs/tags/release-0.4.8
... commit refs/tags/release-0.4.9
It seems that lightweight tags are stored using ObjectIdRef$PeeledNonTag class (I'm not familiar with jgit so I don't know if this is correct). PeeledNonTag.peeledObjectId property is always null so when plugin tries to check name of that property NullPointerException is thrown.
If this is intended to don't support lightweight tags then at least error message should be more specific what caused plugin exception.
I never tried to use axion-release with lightweight tags, so it might be just as you describe it. All newly created tags are always annotated tags. Once the first tag in the tree is annotated tag, everything should be okay as long as you keep away from useHighestVersion option (which scans the whole tree, not just looks for the first tag encountered).
You are right clearer error msg should be in place.