You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins metrics插件执行Maven发布命令安装失败求助

解决Jenkins Metrics插件打包时的Prerequisites警告问题

我之前在构建Jenkins插件的时候也碰到过一模一样的警告,给你几个实用的解决思路:

1. 先搞懂警告的根源

这个警告是说你的metrics插件项目(hpi类型的Jenkins插件)用了prerequisites标签,但这个标签本来是给Maven插件项目(maven-plugin类型)设计的,用来指定运行该插件所需的最低Maven版本。Jenkins插件属于hpi打包类型,不是标准的maven-plugin,所以Maven会抛出这个校验警告。

2. 修复pom.xml配置(推荐方案)

直接修改项目根目录的pom.xml,调整版本声明的方式:

  • 找到并移除原有的prerequisites代码块:
    <prerequisites>
      <maven>3.0</maven>
    </prerequisites>
    
  • 换成用properties来声明Maven版本要求:
    <properties>
      <maven.minimum.version>3.0</maven.minimum.version>
    </properties>
    
  • 同时确保Jenkins插件的打包插件配置正确,比如:
    <build>
      <plugins>
        <plugin>
          <groupId>org.jenkins-ci.tools</groupId>
          <artifactId>maven-hpi-plugin</artifactId>
          <version>3.24</version> <!-- 替换成符合项目要求的版本 -->
          <extensions>true</extensions>
        </plugin>
      </plugins>
    </build>
    

3. 临时忽略警告(仅当不影响构建时)

如果只是警告,后续没有报错,你可以先尝试继续执行构建,或者给Maven加参数忽略这类警告:

apache-maven-3.5.3/bin/mvn release:prepare release:perform -B -Dmaven.compiler.showWarnings=false

不过这种方式只是治标,还是建议修复pom.xml的配置,避免后续可能出现的构建异常。

4. 确认Jenkins插件仓库配置正确

有时候依赖下载异常也会引发连锁问题,检查你的Maven settings.xml,确保配置了Jenkins官方仓库:

<profile>
  <id>jenkins-plugin-repo</id>
  <activeByDefault>true</activeByDefault>
  <repositories>
    <repository>
      <id>jenkins-releases</id>
      <url>https://repo.jenkins-ci.org/releases/</url>
    </repository>
    <repository>
      <id>jenkins-snapshots</id>
      <url>https://repo.jenkins-ci.org/snapshots/</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>jenkins-releases</id>
      <url>https://repo.jenkins-ci.org/releases/</url>
    </pluginRepository>
  </pluginRepositories>
</profile>

内容的提问来源于stack exchange,提问作者dsp

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:09:55