很长一段时间,我有一个Jenkins构建,它执行Sonar作为构建后的动作。它运行良好多年,然后上周开始失败了:
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
...
我认为这是一个相当标准的设置,我们的Nexus上有一个公共回购,它共享Nexus中其他回购的所有内容,例如OOTB Codehaus Snapshots repo。 (是的,我已经四次检查Codehaus快照存储库位于公共存储库的有序组存储库中。)
我不完全了解快照的工作原理,但我的印象是maven-metadata.xml文件告诉客户端快照的哪个版本可供下载。
如果我使用浏览器并直接访问codehaus-snapshots repo,我会获得带有版本信息的maven-metadata.xml:
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>
如果我尝试从公共仓库加载它,则找不到它:
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
如果我将?describe添加到公共回购请求中,我得到:
{ "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"
}
}
}
当我尝试构建声纳:声纳时,我在.m2 / repository / org / codehaus / mojo / sonar-maven-plugin / 2.2-SNAPSHOT中获得了maven-metadata-central.xml,但它缺少版本信息:
<metadata>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.2-SNAPSHOT</version>
</metadata>
所以我认为问题在于公共存储库没有向客户端提供版本信息的maven-metadata.xml,因此客户端尝试在没有版本信息的情况下下载它,并在无法找到时失败它。我是对的吗?
对于我的Nexus(或可能是Jenkins)配置,我需要更改哪些内容才能重新开始工作?
答案 0 :(得分:0)
看起来像groupid已更改为org.codehaus.sonar
请参阅http://snapshots.repository.codehaus.org/org/codehaus/sonar/sonar-maven-plugin/2.2-SNAPSHOT/
答案 1 :(得分:0)
虽然我仍然不了解一些Nexus问题等,但我的构建工作再次开始,我不想让这个问题保持开放。
最初我认为我错过了输出的这一部分:
[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
这让我想知道是什么指定了要使用的声纳版本。我搜索了所有的POM,但实际上没有列出声纳插件。所以我将它添加到父pom.xml的插件部分:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>1.0</version>
</plugin>
......然后构建再次开始工作。我不知道maven在以前工作时从哪里获得了声纳依赖性(如果它从未奏效,那对我来说会有意义),但我想我将不得不忍受这个谜。
答案 2 :(得分:0)
我在Hudson配置中为解决问题所做的更改是Version of sonar-maven-plugin
部分中的Sonar installations
。我尝试使用版本2.0
和2.6
,如果您使用Maven 3.0
,它们都可以使用。
Hudson的Sonar插件默认使用2.2-SNAPSHOT
可用here。要添加我尝试过的工件:
在所有情况下,我无法获得声纳分析的2.2-SNAPSHOT
神器。它反而适用于其他版本。