1

Tried different version but to know avail - 3.0.0 seems to be the latest:

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
            <preparationGoals>clean install</preparationGoals>
        </configuration>
    </plugin>
</plugins>

It works in my local, but in Jenkins it is not: How Jenkins call maven Error in Jenkins

And can not see much needed info about this error: Only [] formats are supported for change recordings

Let me know if I am looking at the wrong place.

Thanks!

pvma
  • 403
  • 8
  • 14
  • First why is the versions plugin in the game? Why have you change the preparationGoals ? The problem is related to the versions-maven-plugin which is not related to maven-release-plugin... the question is how your Jenkins Job is calling Maven??? – khmarbaise Apr 25 '23 at 11:10
  • Not really to say any game this is, I also do not know what the error means. Previously it worked in our Jenkins (for quite some time I have not touched this project), then suddenly did not worked. I have updated the post for Jenkins Job is calling maven – pvma Apr 25 '23 at 12:45

2 Answers2

1

Your problem seems to be caused by outdated Maven version on your Jenkins.

maven-versions-plugin uses JSR-330 for dependency injection, see for example none-recorder or xml-recorder sources:

@javax.inject.Named("none")
public class ChangeRecorderNull implements ChangeRecorder {

@javax.inject.Named("xml")
public class ChangeRecorderXML implements ChangeRecorder {

But in JSR-330 documentation explicitly said:

If you want to use JSR-330, you must understand that your code won't be compatible with Maven 3.0.x but only with Maven 3.1.0 and later. Even though JSR-330 has been available in core since Maven 3.0-beta-3, it was made available to plugins and extensions only in Maven 3.1.0 (see MNG-5343 for more details).

When @Named injection does NOT work you should see symptoms like in your case:

public abstract class AbstractVersionsUpdaterMojo extends AbstractMojo {
    ...
    @Inject
    protected AbstractVersionsUpdaterMojo(
            RepositorySystem repositorySystem,
            org.eclipse.aether.RepositorySystem aetherRepositorySystem,
            Map<String, Wagon> wagonMap,
            Map<String, ChangeRecorder> changeRecorders // <<<< EMPTY MAP INJECTED FOR MAVEN < 3.1
    ) {
        this.repositorySystem = repositorySystem;
        this.aetherRepositorySystem = aetherRepositorySystem;
        this.wagonMap = wagonMap;
        this.changeRecorders = changeRecorders;
    }
    ...
    protected ChangeRecorder getChangeRecorder() throws MojoExecutionException {
        ChangeRecorder changeRecorder = changeRecorders.get(changeRecorderFormat);
        if (changeRecorder == null) {
            throw new MojoExecutionException(
                    "Only " + changeRecorders.keySet() + " formats are supported for change recordings");
        }
        return changeRecorder;
    }

I highly recommend to use Maven Wrapper to keep consistent builds across different environments.

ursa
  • 4,404
  • 1
  • 24
  • 38
  • Thank you for your answer, I would have tried this but my colleague was able to fix it. – pvma Apr 27 '23 at 05:28
  • 1
    it's all the same - older versions of `versions-maven-plugin` don't use JSR-330, thus explicit version `2.13` or older would work for your case. See `plugin api for changerecorder` in release notes https://github.com/mojohaus/versions/releases/tag/2.14.0 – ursa Apr 27 '23 at 16:41
1

Setting this in our Jenkins build fix it: enter image description here From:

-U clean install versions:set -DnewVersion=${version}

To:

-U clean install build-helper:parse-version org.codehaus.mojo:versions-maven-plugin:2.4:set -DnewVersion=${version}
pvma
  • 403
  • 8
  • 14