Jenkins 问题汇总
1. 未安装 Maven
ERROR: A Maven installation needs to be available for this project to be built.Either your server has no Maven installations defined, or the requested Maven version does not exist.
Finished: FAILURE
原因:Jenkins 默认是没有安装 Maven 的。
解决办法:使用全局工具配置,自动安装 Maven。
在pipeline{}
中添加自动下载工具命令
tools {
maven 'Apache-maven-3.8.6'
}
2. 用 SSH 凭证方式连接 Git 失败
Failed to connect to repository : Command "git ls-remote -h -- git@github.com:xxx/xxx.git HEAD" returned status code 128:
stdout:
stderr: No ECDSA host key is known for github.com and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
原因:首次连接可能会出现此错误。
解决办法:Dashboard > Manage Jenkins > Config Global Security 修改验证策略为 Accpt first connection
。
3. 部署 jar 包到 nexus 失败
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project home-api: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
原因:未在pom文件中配置分发管理。
解决办法:在pom.xml
文件中添加distributionManagement
节点,使用分发管理将项目打成jar包,直接上传到指定服务器。
snapshotRepository
是快照版本,repository
是正式版本。
需要注意的是,这里的id
应该与setting.xml
文件中server
节点下的id
相同。
<distributionManagement>
<snapshotRepository>
<id>nexus-public</id>
<name>Nexus Snapshot Repository</name>
<url>http://ori-nexus.com/repository/maven-snapshots/</url>
</snapshotRepository>
<repository>
<id>nexus-public</id>
<name>Nexus Release Repository</name>
<url>http://ori-nexus.com/repository/maven-releases/</url>
</repository>
</distributionManagement>
4. 上传 jar 包再次失败
status: 413 Request Entity Too Large -> [Help 1]
原因:使用了nginx
作为nexus
服务的反向代理,nginx
不允许上传过大的文件。
解决办法:可以把client_max_body_size
根据需要调大。
server {
listen 80;
server_name ori-nexus.com;
client_max_body_size 30M;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
proxy_pass http://nexus:8081;
}
}
重新加载配置文件使之生效:docker exec -it nginx-proxy /usr/sbin/nginx -s reload
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 25岁的心里话