You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
|
|
|
name: master
|
|
|
|
steps:
|
|
|
|
- name: restore-cache
|
|
|
|
image: meltwater/drone-cache
|
|
|
|
settings:
|
|
|
|
backend: filesystem
|
|
|
|
restore: true
|
|
|
|
cache_key: "maven"
|
|
|
|
archive_format: gzip
|
|
|
|
filesystem_cache_root: "/var/lib/cache"
|
|
|
|
mount:
|
|
|
|
- "maven"
|
|
|
|
volumes:
|
|
|
|
- name: cache
|
|
|
|
path: "/var/lib/cache"
|
|
|
|
# Do stuff..
|
|
|
|
- name: build
|
|
|
|
image: maven:3.8-openjdk-8
|
|
|
|
commands: # 定义在Docker容器中执行的shell命令
|
|
|
|
- mvn clean package # 应用打包命令
|
|
|
|
- cp target/demo-1.0.0.jar /app/build/demo-1.0.0.jar
|
|
|
|
- cp Dockerfile /app/build/Dockerfile
|
|
|
|
- cp run.sh /app/build/run.sh
|
|
|
|
- name: deploy-start
|
|
|
|
image: appleboy/drone-ssh # SSH工具镜像
|
|
|
|
settings:
|
|
|
|
host: 121.41.171.43 # 远程连接地址
|
|
|
|
username: root # 远程连接账号
|
|
|
|
password:
|
|
|
|
from_secret: zhangjl808 # 从Secret中读取SSH密码
|
|
|
|
port: 22 # 远程连接端口
|
|
|
|
command_timeout: 5m # 远程执行命令超时时间
|
|
|
|
script:
|
|
|
|
- cd /root/docker/maven/build # 进入宿主机构建目录
|
|
|
|
- chmod +x run.sh # 更改为可执行脚本
|
|
|
|
- ./run.sh # 运行脚本打包应用镜像并运行
|
|
|
|
when:
|
|
|
|
event:
|
|
|
|
- promote
|
|
|
|
volumes:
|
|
|
|
- name: cache
|
|
|
|
host:
|
|
|
|
path: "/var/lib/cache"
|
|
|
|
trigger:
|
|
|
|
branch:
|
|
|
|
- master
|
|
|
|
event:
|
|
|
|
- push
|
|
|
|
- merge
|