Jenkins和Maven集成
使用
借助jenkins在服务器中打包成docker镜像并运行项目。
步骤
- 在jenkins中构建一个自由风格的软件项目
- 填写git信息
- 指定分支
- maven构建,这里执行的目标
这里有个注意的点,就是这个执行的deploy命令的时候,加了一个-U,
-U,–update-snapshots Forces a check for missing releases and updated snapshots on remote repositories,这个-U的意思是强制更新依赖的jar包
因为有的项目执行的时候,依赖包会报错,报错的内容为
[ERROR] Failed to execute goal on project etoplive: Could not resolve dependencies for project com.xxx:etoplive:jar:1.0-SNAPSHOT: com.xxx:etoplive-provider:jar:1.1 was not found in http://xxx:18081/repository/private-release/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of xxx.xx has elapsed or updates are forced -> [Help 1]
意思是找不到这个jar包,因为默认的私有仓库的jar包刷新时间是按照天来的,但是发布的频率肯定不行,如果第一次拉取失败了,那么今天就会一直报这个错误,也试了改版本号,最终也没有拉取下来,所以加了这个-U就能强制更新了。
- 增加执行的shell
这里边就是对打好的jar包,进行一个docker build,和推送,和启动,具体使用和docker无异