-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy path.drone.yml
174 lines (164 loc) · 4.84 KB
/
.drone.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
kind: pipeline
type: docker
name: default
steps:
- name: resource all in
image: nas.mrcms.cn:8082/wuweiit/alpine:3.20.2
pull: if-not-exists
volumes:
- name: joggle-admin-out
path: /drone/admin
- name: joggle-web-out
path: /drone/web
- name: ssh
path: /root/.ssh
commands:
- chmod 600 /root/.ssh/id_rsa
- echo "copy admin manager web..."
- scp -rp -o StrictHostKeyChecking=no /drone/admin/dist/* ./joggle-server/src/main/resources/static/manager/;
- echo "copy web..."
- scp -rp -o StrictHostKeyChecking=no /drone/web/* ./joggle-server/src/main/resources/static/;
- echo "修改版本号 $DRONE_BUILD_BUMBER ";
- sed -ie "s/dev-version/$DRONE_BUILD_BUMBER/g" ./joggle-server/src/main/resources/static/js/faceinner.ajax.js
when:
branch:
- dev
- test
- release
- name: build
image: maven:3.8.6-jdk-8-slim
pull: if-not-exists # 如果镜像不存在则拉取,免去每次都要重新下载
volumes:
- name: mavenRep
path: /root/.m2
commands:
- echo 构建号:${DRONE_BRANCH}
- echo "识别环境 决定资源"
- if [ "${DRONE_BRANCH}" != "prod" ]; then echo 'prod' ;fi
- mvn package -DskipTests=true -Dmaven.javadoc.skip=true -U
- mv joggle-server/target/joggle-server.jar joggle-server/target/app.jar
branch:
- dev
- test
- prod
- release
- name: scp to ${DRONE_BRANCH}
image: appleboy/drone-scp
pull: if-not-exists # 如果镜像不存在则拉取,免去每次都要重新下载
# environment:
# SSH_KEY_PATH: /root/.ssh/id_rsa
volumes:
- name: ssh
path: /root/.ssh
settings:
host: 192.168.1.6
username: root
key:
from_secret: ssh_rsa
port: 22
strip_components: 2
target: /opt/data/joggle/
source: joggle-server/target/app.jar
when:
branch:
- test
- name: scp to prod jar
image: appleboy/drone-scp
pull: if-not-exists # 如果镜像不存在则拉取,免去每次都要重新下载
environment:
SSH_KEY_PATH: /root/.ssh/id_rsa
volumes:
- name: ssh
path: /root/.ssh
settings:
host: joggle.cn
username: root
keyPath: /root/.ssh/id_rsa
port: 22
strip_components: 2
target: /opt/data/joggle/prod/
source: joggle-server/target/app.jar
when:
branch:
- prod
- name: release docker image
image: plugins/docker
pull: if-not-exists # 如果镜像不存在则拉取,免去每次都要重新下载
volumes:
- name: dockerSock
path: /var/run/docker.sock
settings:
insecure: false
registry: nexus.mrcms.cn:8083
mirror: https://dkwe3jow.mirror.aliyuncs.com
storage_path: /docker
dockerfile: Dockerfile
build_args: JAR=./joggle-server/target/app.jar
username:
from_secret: registry_nexus_username
password:
from_secret: registry_nexus_password
repo: nexus.mrcms.cn:8083/wuweiit/joggle-server
tags:
- ${DRONE_BUILD_NUMBER}
when:
branch:
- release
- name: deploy-to-test
pull: if-not-exists
image: registry.cn-hangzhou.aliyuncs.com/sanchar/kubectl:v1.20.1
extra_hosts:
- lb.kubesphere.local:192.168.1.6
volumes:
- name: kube
path: /root/.kube
commands:
# - kubectl --kubeconfig /root/.kube/config set image deployment/joggle *='nas.mrcms.cn:8082/wuweiit/joggle-server:${DRONE_BUILD_NUMBER}' -n home
- kubectl --kubeconfig /root/.kube/config rollout restart deployment/joggle -n home
when:
branch:
- test
# - name: clean image
# image: plugins/docker
# pull: if-not-exists
# volumes:
# - name: dockerSock
# path: /var/run/docker.sock
# commands:
# - if [ "${DRONE_BRANCH}" = "dev" ];then docker rmi -f $(docker image ls --filter=reference="192.168.1.6:32588/wuweiit/joggle-server:*" -q); fi
# - if [ "${DRONE_BRANCH}" = "test" ];then docker rmi -f $(docker image ls --filter=reference="registry.cn-chengdu.aliyuncs.com/paazhi/${DRONE_REPO_NAME}:*" -q); fi
# - if [ "${DRONE_BRANCH}" = "prod" ];then docker rmi -f $(docker image ls --filter=reference="registry.cn-chengdu.aliyuncs.com/panzhi/${DRONE_REPO_NAME}:*" -q); fi
# when:
# branch:
# - dev
# - test
# - prod
volumes:
- name: joggle-web-out
host:
path: /opt/build/joggle-web
- name: joggle-admin-out
host:
path: /opt/build/joggle-admin
- name: ssh
host:
path: /root/.ssh
- name: kube
host:
path: /root/.kube
- name: mavenRep
host:
path: /opt/data/drone/.m2
- name: dockerSock
host:
path: /var/run/docker.sock
trigger:
event:
include:
- push
- custom
branch:
- prod
- test
# - dev
- release