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

Jenkins执行maven-compiler-plugin编译失败,IntelliJ执行正常求助

解决Jenkins构建Maven项目时compile报错"Error while storing the mojo status: Input length = 1"的方案

以下是针对该问题的具体解决步骤:

  • 检查Jenkins工作空间权限
    Jenkins运行用户可能没有读写项目工作空间的权限,导致无法存储mojo状态文件。Linux系统可执行命令修改权限:

    chown -R jenkins:jenkins /var/lib/jenkins/workspace/automation-framework
    

    Windows系统右键工作空间文件夹,给Jenkins服务运行用户添加读写权限。

  • 升级maven-compiler-plugin版本
    当前使用的3.11.0版本可能存在兼容性问题,建议显式指定更高稳定版本(如3.12.1),在pom.xml中添加build节点配置:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.12.1</version>
                <configuration>
                    <source>17</source>
                    <target>17</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
  • 清理Jenkins本地Maven仓库缓存
    Jenkins的Maven本地仓库可能存在损坏的依赖包,找到Jenkins配置的Maven仓库路径(可在全局工具配置中查看),删除org/example/automation-framework相关文件夹,或直接清空仓库后重新构建。

  • 强制指定系统编码为UTF-8
    即使pom中指定了编码,Jenkins服务器的系统编码可能不匹配,导致文件读取异常。在Jenkins构建步骤中先添加编码设置:
    Linux环境执行shell:

    export LANG=en_US.UTF-8
    mvn clean compile
    

    Windows环境执行批处理命令:

    chcp 65001
    mvn clean compile
    
  • 禁用Maven增量编译
    增量编译的状态存储机制可能出现异常,修改Jenkins构建目标为:

    clean compile -Dmaven.compiler.useIncrementalCompilation=false
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 13:52:49