weverse-api/.drone.yml
2025-02-10 13:57:32 +08:00

65 lines
2.8 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 # 定义对象类型还有secret和signature两种类型
type: docker # 定义流水线类型还有kubernetes、exec、ssh等类型
name: weverse-api # 定义流水线名称
steps: # 定义流水线执行步骤,这些步骤将顺序执行
- name: package # 1. 流水线名称maven打包
pull: if-not-exists
image: maven:3.8.8 # 定义创建容器的Docker镜像
volumes: # 将容器内目录挂载到宿主机仓库需要开启Trusted设置
- name: maven-cache
path: /root/.m2 # 将maven下载依赖的目录挂载出来防止重复下载
# 挂载宿主机的目录
- name: maven-build
path: /app/build/weverse-api # 将应用打包好的Jar和执行脚本挂载出来
commands: # 定义在Docker容器中执行的shell命令,这里是复制到maven镜像容器里面的区分开项目就行了
- mvn clean package -Dmaven.test.skip=true
- cp ruoyi-admin/target/ruoyi-admin.jar /app/build/weverse-api/weverse-api.jar
- cp Dockerfile /app/build/weverse-api/Dockerfile
- cp run.sh /app/build/weverse-api/run.sh
# - name: code-analysis # 代码分析
# image: aosapps/drone-sonar-plugin
# settings:
# sonar_host:
# from_secret: sonar_host
# sonar_token:
# from_secret: sonar_token
- name: build-start # 2. 流水线名称ssh默认人工操作打包好的jar包
image: appleboy/drone-ssh:1 # ssh工具镜像
settings:
host:
from_secret: ssh_host # 远程连接地址,可以是IP可以是域名
username:
from_secret: ssh_user # 远程连接账号
# password: 123456 #明文密码
password:
from_secret: ssh_password # 从Secret中读取SSH密码
# key:
# from_secret: ssh_key # 从Secret中读取SSH密钥
port: 22 # 远程连接端口
command_timeout: 10m # 远程执行命令超时时间
script_stop: false # 设置为false遇到第一次错误会继续运行后面的命令
script:
- cd /home/d1/maven/build/weverse-api # 进入宿主机构建目录,可根据自己选择目录
- sudo chmod +x run.sh # 更改为可执行脚本
- ./run.sh # 运行脚本打包应用镜像并运行
# - name: notify # 3. 通知(这里使用了钉钉通知,可以使用微信通知、邮件通知等)
# pull: if-not-exists
# image: guoxudongdocker/drone-dingtalk:latest
# settings:
# token:
# from_secret: dingtalk_token
# type: markdown
# message_color: true
# message_pic: true
# sha_link: true
# when:
# status: [failure, success]
volumes: # 定义流水线挂载目录,用于共享数据
- name: maven-build
host:
path: /home/d1/maven/build/weverse-api # 从宿主机中挂载的目录
- name: maven-cache
host:
path: /home/d1/maven/cache