71 lines
2.4 KiB
YAML
71 lines
2.4 KiB
YAML
# .woodpecker.yaml
|
|
|
|
# 💡 全局变量块 42
|
|
variables:
|
|
- &APP_REGISTRY "push.lovestory.cyou"
|
|
- &APP_PULL_REGISTRY "registry.lovestory.cyou"
|
|
- &PROJECT_NAME "abhors/demo"
|
|
- &CONTAINER_NAME "demo-container"
|
|
- &DEPLOY_HOST "43.143.243.136"
|
|
- &DEPLOY_PORT "22"
|
|
- &DEPLOY_USER_SECRET "136_ssh_user"
|
|
- &DEPLOY_PASS_SECRET "136_ssh_password"
|
|
|
|
steps:
|
|
- name: Java 构建
|
|
image: library/maven:3.9.6-eclipse-temurin-17
|
|
pull: true
|
|
commands:
|
|
- mvn clean package -DskipTests
|
|
volumes:
|
|
- /tmp/maven-cache:/root/.m2
|
|
when:
|
|
event: [push, pull_request]
|
|
branch: master
|
|
|
|
- name: 镜像构建与推送
|
|
image: woodpeckerci/plugin-docker-buildx:latest
|
|
privileged: true
|
|
environment:
|
|
REGISTRY_DOMAIN: *APP_REGISTRY
|
|
PROJECT_PATH: *PROJECT_NAME
|
|
settings:
|
|
repo: ${REGISTRY_DOMAIN}/${PROJECT_PATH}
|
|
|
|
# 💡 文档高级配置:通知内部 dockerd 引擎全面放开对不安全 HTTP 仓库的拦截
|
|
insecure: true
|
|
|
|
# 💡 官方文档标准语法:改用新版 logins 数组来显式声明私服的登录凭证
|
|
logins:
|
|
- registry: "http://push.lovestory.cyou" # 👈 显式加上 http://,强制按纯 HTTP 协议走
|
|
username:
|
|
from_secret: nexus_docker_username
|
|
password:
|
|
from_secret: nexus_docker_password
|
|
when:
|
|
event: push
|
|
branch: master
|
|
|
|
- name: 远程终端部署
|
|
image: registry.lovestory.cyou/appleboy/drone-ssh:latest
|
|
settings:
|
|
host: *DEPLOY_HOST
|
|
port: *DEPLOY_PORT
|
|
username:
|
|
from_secret: *DEPLOY_USER_SECRET
|
|
password:
|
|
from_secret: *DEPLOY_PASS_SECRET
|
|
secrets: [ nexus_docker_username, nexus_docker_password ]
|
|
envs: [ nexus_docker_username, nexus_docker_password ]
|
|
script:
|
|
- echo "========================================="
|
|
- echo "🚀 开始部署节点:*DEPLOY_HOST"
|
|
- echo "========================================="
|
|
- docker login --username "$nexus_docker_username" --password "$nexus_docker_password" "registry.lovestory.cyou"
|
|
- docker stop "demo-container" || true
|
|
- docker rm "demo-container" || true
|
|
- docker pull "registry.lovestory.cyou/abhors/demo:latest"
|
|
- docker run -d --name "demo-container" -p 8080:8080 --restart always "registry.lovestory.cyou/abhors/demo:latest"
|
|
when:
|
|
event: push
|
|
branch: master |