记录我jenkins dockerfile-maven-plugin 构建的惨痛过程
- 1、no plugin found for prefix 'dockerfile' in the current project and in the plugin groups
- 2 pom 文件找不到了
- 3、jenkins访问docker 权限 问题
- 4、error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/
- 5、 docker 向私有仓库推送报错Error response from daemon: Get https://192.168.1.55:5000 http: server gave HTTP response to HTTPS client
- 6、我以为 build success 万万没想到
闲来无事自己通过虚拟机搭建了一个jenkins,想通过dockerfile-maven-plugin 插件结合dockerfile 直接推到私有仓库,结果构建项目就失败了n次,为了以后绕开这些坑,写了这篇博客
1、no plugin found for prefix ‘dockerfile’ in the current project and in the plugin groups
网上基本都是 需要向maven的settings文件中配置白名单
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
</plugin>
试了没什么用,我到var/lib/jenkins/.m2/repository 里面看了下,jar包并没有下下来,看了下jenkins maven配置,没啥毛病,只能重新配置,不用本地的用jenkins自己下载的,删掉之前repository里的所有jar包。重新download。结果就报了第二个错误 --!
2 pom 文件找不到了
报错没有截图,var/lib/jenkins/workspace/mytest 这个目录下没有找到pom文件,应该是jenkins配置问题。
直接在构建之前切换下目录,并跳过测试
cd demo
mvn clean install -Dmaven.test.skip=true dockerfile:build dockerfile:push
3、jenkins访问docker 权限 问题
直接上解决方法:
修改配置文件
vim /etc/sysconfig/jenkins
jenkins改成root
$JENKINS_USER="root"
修改Jenkins相关文件夹用户权限
chown -R root:root /var/lib/jenkins
chown -R root:root /var/cache/jenkins
chown -R root:root /var/log/jenkins
然后重启docker
service jenkins restart 解决
4、error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/
应该dns 域名解析有问题
vi /etc/resolv.conf 在加一个解析服务器
nameserver 8888
意思是第一个解析没有结果的时候会用下一个。然后重启docker
5、 docker 向私有仓库推送报错Error response from daemon: Get https://192.168.1.55:5000 http: server gave HTTP response to HTTPS client
docker 推送默认是https 的所以需要配置下 daemon.json
vim /etc/docker/daemon.json
"insecure-registries":["私有仓库ip:端口号"]
ok 问题解决。
6、我以为 build success 万万没想到
黄色代表其他错误(才知道),我的是因为单元测试报错
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
改了下版本,之前是5.5.0的,最后成功 。主要问题就是这些,实际一些小问题并没有记,基本都是网上有对应的解决办法,我只是做了下整理。