@@ -100,7 +100,7 @@ docker compose down # 停止并删除与 Docker Compose 配置文件相关的
100
100
101
101
<img src="./imgs/0-3.png" width="620" />
102
102
103
- # # 2. 添加凭证
103
+ # # 2. 添加凭据
104
104
105
105
<img src="./imgs/1.png" width="620" />
106
106
@@ -110,6 +110,14 @@ docker compose down # 停止并删除与 Docker Compose 配置文件相关的
110
110
111
111
<img src="./imgs/4.png" width="620" />
112
112
113
+ 添加 `SSH` 和 `SCP` 需要的凭据
114
+
115
+ <img src="./imgs/4-1.png" width="620" />
116
+
117
+ ` ssh-keygen -t rsa` 生成 `id_rsa` 和 `id_rsa.pub` 文件,将 `id_rsa` 私钥文本复制到 `jenkins` 中
118
+
119
+ <img src="./imgs/4-2.png" width="620" />
120
+
113
121
# # 3. 新建工作流
114
122
115
123
<img src="./imgs/5.png" width="620" />
@@ -177,19 +185,19 @@ pipeline {
177
185
}
178
186
}
179
187
environment {
180
- def git_url="http://152.22.3.186:8081/mall/h5.git"
181
- def git_auth = "12312312-f199-4b15-b087-123123"
182
- def git_branch = "${branch}"
183
- def project_env = "${project_env}"
184
- def data_dir = "/mnt/mall/h5/h5_vip"
185
-
186
- // 本地需要上传的目录 以及远程服务器的目录
187
- def localDir = "${WORKSPACE}/h5_vip/test_dir/"
188
- def vip_host = '152.22.3.186'
189
- def vip_remote_dir = "/mnt/mall/h5"
188
+ def git_url="http://152.22.3.186:8081/mall/h5.git"
189
+ def git_auth = "12312312-f199-4b15-b087-123123"
190
+ def git_branch = "${branch}"
191
+ def project_env = "${project_env}"
192
+ def data_dir = "/mnt/mall/h5/h5_vip"
193
+
194
+ // 本地需要上传的目录 以及远程服务器的目录
195
+ def localDir = "${WORKSPACE}/h5_vip/test_dir/"
196
+ def vip_host = '152.22.3.186'
197
+ def vip_remote_dir = "/mnt/mall/h5"
190
198
}
191
199
stages {
192
- stage('Git Checkout'){
200
+ stage('Git Checkout') {
193
201
steps {
194
202
echo "🏆 WORKSPACE: 【${WORKSPACE}】"
195
203
echo "🎯 branch: 【${git_branch}】"
@@ -210,16 +218,15 @@ pipeline {
210
218
sh 'ls -la'
211
219
}
212
220
}
213
- }
214
221
stage('Send Files') {
215
222
when {
216
223
expression {
217
224
currentBuild.result == null || currentBuild.result == 'SUCCESS'
218
225
}
219
226
}
220
- steps {
227
+ steps {
221
228
sh 'pwd'
222
- script{
229
+ script {
223
230
switch (project_env) {
224
231
case "vip":
225
232
sh '''
@@ -247,7 +254,6 @@ pipeline {
247
254
// sh "scp -r -o StrictHostKeyChecking=no -i /var/lib/jenkins/.ssh/id_rsa -P 22 '${WORKSPACE}/h5_vip/' '$i:${data_dir}'"
248
255
// }
249
256
break
250
-
251
257
}
252
258
}
253
259
}
0 commit comments