前记
最近在部署一个由 Guns
开发的一套系统,在本地测试和 Gitlab Runner
上执行 mvn package -B -Dmaven.test.skip=true
都能跳过测试,但是在 CI
里面就没法跳过测试
解决方案
在 pom
中加入 maven-surefire-plugin
并跳过测试
1 2 3 4 5 6 7 8
| <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M3</version> <configuration> <skipTests>true</skipTests> </configuration> </plugin>
|
Guns
这里我们再介绍哈 guns
多模块打包方案,模块如下:
- guns-parent
父模块
- guns-core
guns核心模块
- guns-generator
代码生成模块
- guns-admin
后台管理模块
- guns-rest
API模块
下面是 CI
文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| before_script: - rm -rf /data/ - mkdir -p /data/ - mv * .git* /data/ - cd /data/
stages: - deploy
maven-build: stage: deploy only: - master script: - cd guns - mvn clean install - cd ../guns/guns-admin - mvn package -B -Dmaven.test.skip=true - docker build ... - docker tag ... - docker push ... - cd ../../guns/guns-rest - mvn package -B -Dmaven.test.skip=true - docker build ... - docker tag ... - docker push ... tags: - spring-boot-shell
|
关于构建的 Dockerfile
可以参考
1 2 3 4
| FROM openjdk:8-jdk-alpine VOLUME /tmp COPY target/guns-admin-1.0.0.jar app.jar ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|