SpringBoot-Hr/.drone.yml

61 lines
1.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

kind: pipeline
type: docker
name: testxxx
steps:
# 1.maven打包
- name: maven compile
pull: if-not-exists
# 构建镜像的maven+jdk选择最好选择满足匹配你的项目版本的
image: adoptopenjdk/maven-openjdk8
volumes:
# maven构建缓存
- name: maven-cache
path: /root/.m2
# 挂载宿主机的目录
- name: maven-build
path: /drone/build
commands:
# 开始打包maven工程
- mvn clean package -Dmaven.test.skip=true
# 将打包后的文件复制到宿主机映射目录
- cp target/*.jar /drone/build
- cp Dockerfile /drone/build
- cp docker.sh /drone/build
- cp start.sh /drone/build
- name: build docker
image: plugins/docker
volumes:
# 将容器内目录挂载到宿主机仓库需要开启Trusted设置
- name: maven-build
path: /drone/build # 将应用打包好的Jar和执行脚本挂载出来
- name: docker
path: /var/run/docker.sock # 挂载宿主机的docker
settings:
dockerfile: /drone/build/Dockerfile
commands:
# 定义在Docker容器中执行的shell命令
- cd /drone/build
- chmod +x docker.sh
- sh docker.sh
- docker ps
volumes: # 定义流水线挂载目录,用于共享数据
- name: maven-build
host:
path: /home/zeroerr/drone/maven/build # 从宿主机中挂载的目录
- name: maven-cache
host:
path: /home/zeroerr/drone/maven/cache
- name: docker
host:
path: /var/run/docker.sock
# drone执行触发器
trigger:
branch:
- master