0
votes

For a long time, I have had a Jenkins build which executes Sonar as a post-build action. It has run fine for years, then last week started failing with this:

Downloading: http://myNexusServer/nexus/content/groups/public/org/codehaus/mojo/sonar-maven-plugin/2.2-SNAPSHOT/sonar-maven-plugin-2.2-SNAPSHOT.pom
Downloading: http://myNexusServer/nexus/content/groups/public/org/codehaus/mojo/sonar-maven-plugin/2.2-SNAPSHOT/sonar-maven-plugin-2.2-SNAPSHOT.jar
[INFO] Unable to find resource 'org.codehaus.mojo:sonar-maven-plugin:maven-plugin:2.2-SNAPSHOT' in repository central (http://central)
[INFO] Cannot find mojo descriptor for: 'sonar:sonar' - Treating as non-aggregator.
[INFO] ------------------------------------------------------------------------
[INFO] Building portal
[INFO]    task-segment: [sonar:sonar]
[INFO] ------------------------------------------------------------------------
Downloading: http://myNexusServer/nexus/content/groups/public/org/codehaus/mojo/sonar-maven-plugin/2.2-SNAPSHOT/sonar-maven-plugin-2.2-SNAPSHOT.jar
[INFO] Unable to find resource 'org.codehaus.mojo:sonar-maven-plugin:maven-plugin:2.2-SNAPSHOT' in repository central (http://central)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] A required plugin was not found: Plugin could not be found - check that the goal name is correct: Unable to download the artifact from any repository
...

I have what I think is a fairly standard setup, with a public repo on our Nexus that shares all the content of the other repos in the Nexus, such as the OOTB Codehaus Snapshots repo. (Yes I have quadruple-checked that the Codehaus Snapshots repo is in the Ordered Group Repositories of the public repo.)

I don't completely understand how snapshots work, but I'm under the impression that the maven-metadata.xml file tells the client which version/s of the snapshot are available for download.

If I use a browser and go directly to the codehaus-snapshots repo, I get maven-metadata.xml with the version info:

http://myNexusServer/nexus/service/local/repositories/codehaus-snapshots/content/org/codehaus/mojo/sonar-maven-plugin/2.2-SNAPSHOT/maven-metadata.xml

<metadata modelVersion="1.1.0">
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>sonar-maven-plugin</artifactId>
    <version>2.2-SNAPSHOT</version>
    <versioning>
        <snapshot>
            <timestamp>20131108.154049</timestamp>
            <buildNumber>1</buildNumber>
        </snapshot>
        <lastUpdated>20131108154049</lastUpdated>
        <snapshotVersions>
            <snapshotVersion>
                <extension>jar</extension>
                <value>2.2-20131108.154049-1</value>
                <updated>20131108154049</updated>
            </snapshotVersion>
            <snapshotVersion>
                <extension>pom</extension>
                <value>2.2-20131108.154049-1</value>
                <updated>20131108154049</updated>
            </snapshotVersion>
        </snapshotVersions>
    </versioning>
</metadata>

If I try to load it from the public repo, it's not found:

http://myNexusServer/nexus/content/groups/public/org/codehaus/mojo/sonar-maven-plugin/2.2-SNAPSHOT/maven-metadata.xml
The server has not found anything matching the request URI

If I add the ?describe to the request to the public repo, I get:

{ "data" : { "processingTimeMillis" : 108,
    "request" : { "requestContext" : [ "request.received.timestamp=1384808412437",
        "request.address=my.ip.addy",
        "request.remoteOnly=false",
        "request.url=http://myNexusServer/nexus/content/groups/public/org/codehaus/mojo/sonar-maven-plugin/2.2-SNAPSHOT/maven-metadata.xml?describe",
        "request.localOnly=false",
        "request.appRootUrl=http://myNexusServer/nexus"
        ],
        "requestPath" : "/org/codehaus/mojo/sonar-maven-plugin/2.2-SNAPSHOT/maven-metadata.xml",
        "requestUrl" : "http://myNexusServer/nexus/content/groups/public/org/codehaus/mojo/sonar-maven-plugin/2.2-SNAPSHOT/maven-metadata.xml?describe"
    },
    "requestUrl" : "http://myNexusServer/nexus/content/groups/public/org/codehaus/mojo/sonar-maven-plugin/2.2-SNAPSHOT/maven-metadata.xml?describe",
    "response" : { "appliedMappings" : [ "public repository applied []" ],
        "processedRepositoriesList" : [ "public",
            "releases",
            "snapshots",
            "thirdparty",
            "central",
            "java.net-m2",
            "java.net-m1-m2",
            "google",
            "apache-snapshots",
            "codehaus-snapshots",
            "sonatype.public",
            "com.springsource.repository.bundles.release",
            "sonar.repo",
            "com.springsource.repository.bundles.external"
        ],
        "responseType" : "NOT_FOUND"
    }
}
}

When I try to build sonar:sonar, I get a maven-metadata-central.xml in .m2/repository/org/codehaus/mojo/sonar-maven-plugin/2.2-SNAPSHOT, but it is missing the version info:

<metadata>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>sonar-maven-plugin</artifactId>
    <version>2.2-SNAPSHOT</version>
</metadata>

So I think the problem is that the public repo is not providing the maven-metadata.xml to the client with the version information, so the client tries to download it without the version information, and fails when it can't find it. Am I right about that?

What do I need to change about either my Nexus (or possibly Jenkins) configuration to make this work again?

3

3 Answers

0
votes

While I still don't understand some of the Nexus issues, etc, I've got my build working again and I didn't want to leave this open.

Initially I think I missed this section of the output:

[INFO] Searching repository for plugin with prefix: 'sonar'.
[INFO] org.apache.maven.plugins: checking for updates from central
[INFO] org.codehaus.mojo: checking for updates from central
[INFO] artifact org.codehaus.mojo:sonar-maven-plugin: checking for updates from central
[INFO] Ignoring available plugin update: 2.2 as it requires Maven version 3.0

This got me to wondering what was specifying the version of sonar to be used. I searched all of my POMs and none actually listed the sonar plugin. So I added this to the plugins section of the parent pom.xml:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>sonar-maven-plugin</artifactId>
    <version>1.0</version>
</plugin>

...and the build started working again. I don't know where maven was getting the sonar dependency from back when this was working before (it would make sense to me if it never worked), but I suppose I'll have to live with the mystery.

0
votes

What I changed in my Hudson configuration to solve the issue is the Version of sonar-maven-plugin in the Sonar installations section. I tried with version 2.0 and 2.6 and are both working if you use Maven 3.0.

The Sonar plugin for Hudson seems using by default the 2.2-SNAPSHOT available here. To add the artifact I tried to:

  1. Add the nexus.codehaus.org as a proxy repo in my Nexus
  2. Upload the artifact manually
  3. Upload the artifact manually to a second Nexus with different version because the first one was causing metadata corruption

In all the cases I was unable to obtain the 2.2-SNAPSHOT artifact for the Sonar analysis. It instead worked for the other versions.