|
|
|
@ -3,111 +3,6 @@ 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
|
|
|
|
|
volumes: # 将容器内目录挂载到宿主机,仓库需要开启Trusted设置
|
|
|
|
|
- name: maven-build
|
|
|
|
|
path: /app/build # 将应用打包好的Jar和执行脚本挂载出来
|
|
|
|
|
commands:
|
|
|
|
|
- mkdir /root/.m2
|
|
|
|
|
- cp /usr/share/maven/ref/settings-docker.xml /root/.m2/settings.xml
|
|
|
|
|
- sed -i 's/\\/usr\\/share\\/maven\\/ref\\/repository/\\/drone\\/src\\/maven/g' /root/.m2/settings.xml
|
|
|
|
|
- mvn package
|
|
|
|
|
- cp test_zabbix-0.0.1-SNAPSHOT.jar /app/build/app.jar
|
|
|
|
|
- cp Dockerfile /app/build/Dockerfile
|
|
|
|
|
- cp run.sh /app/build/run.sh
|
|
|
|
|
- name: rebuild-cache
|
|
|
|
|
image: meltwater/drone-cache
|
|
|
|
|
settings:
|
|
|
|
|
backend: filesystem
|
|
|
|
|
rebuild: true
|
|
|
|
|
cache_key: "maven"
|
|
|
|
|
archive_format: gzip
|
|
|
|
|
filesystem_cache_root: "/var/lib/cache"
|
|
|
|
|
mount:
|
|
|
|
|
- "maven"
|
|
|
|
|
volumes:
|
|
|
|
|
- name: cache
|
|
|
|
|
path: "/var/lib/cache"
|
|
|
|
|
# - name: scp files
|
|
|
|
|
# image: appleboy/drone-scp
|
|
|
|
|
# settings:
|
|
|
|
|
# host: 121.41.171.43
|
|
|
|
|
# username:
|
|
|
|
|
# from_secret: linac
|
|
|
|
|
# password:
|
|
|
|
|
# from_secret: linac
|
|
|
|
|
# port: 22
|
|
|
|
|
# target: /root
|
|
|
|
|
# source: /target/*
|
|
|
|
|
- name: ssh
|
|
|
|
|
image: appleboy/drone-ssh
|
|
|
|
|
settings:
|
|
|
|
|
host: 192.168.230.16
|
|
|
|
|
username:
|
|
|
|
|
from_secret: user
|
|
|
|
|
password:
|
|
|
|
|
from_secret: secret
|
|
|
|
|
port: 22
|
|
|
|
|
command_timeout: 5m
|
|
|
|
|
script:
|
|
|
|
|
- cd /data/wwwroot/zabbix_back # 进入宿主机构建目录
|
|
|
|
|
- chmod +x run.sh # 更改为可执行脚本
|
|
|
|
|
- ./run.sh # 运行脚本打包应用镜像并运行
|
|
|
|
|
# - name: docker
|
|
|
|
|
# image: plugins/docker
|
|
|
|
|
# settings:
|
|
|
|
|
# dockerfile: "Dockerfile"
|
|
|
|
|
# username:
|
|
|
|
|
# from_secret: docker_username
|
|
|
|
|
# password:
|
|
|
|
|
# from_secret: docker_password
|
|
|
|
|
# tags:
|
|
|
|
|
# - master
|
|
|
|
|
- name: notify
|
|
|
|
|
pull: if-not-exists # 如果镜像不存在则拉取,免去每次都要重新下载
|
|
|
|
|
image: drillster/drone-email
|
|
|
|
|
settings:
|
|
|
|
|
recipients_only: true # 只发送给指定邮件收件人,不默认发送给流水线创建人
|
|
|
|
|
host: smtp.163.com #SMTP服务器 例如 smtp.qq.com
|
|
|
|
|
port: 465 #SMTP服务端口 例如QQ邮箱端口465
|
|
|
|
|
subject: "Drone Build Complete!" # 邮件主题内容
|
|
|
|
|
username: #邮箱用户名
|
|
|
|
|
from_secret: mail_user
|
|
|
|
|
password: #邮箱密码
|
|
|
|
|
from_secret: mail_secret
|
|
|
|
|
from:
|
|
|
|
|
from_secret: mail_username
|
|
|
|
|
recipients: #收件人
|
|
|
|
|
from_secret: mail_recipients # 格式:xxxx,xxxx
|
|
|
|
|
when: #执行条件
|
|
|
|
|
status:
|
|
|
|
|
- success
|
|
|
|
|
- changed
|
|
|
|
|
- failure
|
|
|
|
|
volumes: # 定义流水线挂载目录,用于共享数据
|
|
|
|
|
- name: maven-build
|
|
|
|
|
host:
|
|
|
|
|
path: /data/wwwroot/zabbix_back # 从宿主机中挂载的目录
|
|
|
|
|
- name: cache
|
|
|
|
|
host:
|
|
|
|
|
path: "/var/lib/cache"
|
|
|
|
|
trigger:
|
|
|
|
|
branch:
|
|
|
|
|
- master
|
|
|
|
|
event:
|
|
|
|
|
- push
|
|
|
|
|
- merge
|
|
|
|
|
image: alpine/git
|
|
|
|
|
commands:
|
|
|
|
|
- echo 你好...
|