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.

52 lines
1.4 KiB

2 years ago
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
2 years ago
- name: deploy-start
image: appleboy/drone-ssh # SSH工具镜像
settings:
2 years ago
host: 121.41.171.43 # 远程连接地址
2 years ago
username: root # 远程连接账号
password:
2 years ago
from_secret: zhangjl808 # 从Secret中读取SSH密码
2 years ago
port: 22 # 远程连接端口
command_timeout: 5m # 远程执行命令超时时间
script:
- cd /root/docker/maven/build # 进入宿主机构建目录
- chmod +x run.sh # 更改为可执行脚本
- ./run.sh # 运行脚本打包应用镜像并运行
when:
event:
- promote
2 years ago
volumes:
- name: cache
host:
path: "/var/lib/cache"
trigger:
branch:
- master
event:
- push
- merge