Skip to content

Commit

Permalink
doc: update jenkins document.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 22, 2024
1 parent 997534c commit 9b1a441
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions docs/jenkins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ docker compose down # 停止并删除与 Docker Compose 配置文件相关的

<img src="./imgs/0-3.png" width="620" />

## 2. 添加凭证
## 2. 添加凭据

<img src="./imgs/1.png" width="620" />

Expand All @@ -110,6 +110,14 @@ docker compose down # 停止并删除与 Docker Compose 配置文件相关的

<img src="./imgs/4.png" width="620" />

添加 `SSH` 和 `SCP` 需要的凭据

<img src="./imgs/4-1.png" width="620" />

`ssh-keygen -t rsa` 生成 `id_rsa` 和 `id_rsa.pub` 文件,将 `id_rsa` 私钥文本复制到 `jenkins` 中

<img src="./imgs/4-2.png" width="620" />

## 3. 新建工作流

<img src="./imgs/5.png" width="620" />
Expand Down Expand Up @@ -177,19 +185,19 @@ pipeline {
}
}
environment {
def git_url="http://152.22.3.186:8081/mall/h5.git"
def git_auth = "12312312-f199-4b15-b087-123123"
def git_branch = "${branch}"
def project_env = "${project_env}"
def data_dir = "/mnt/mall/h5/h5_vip"
// 本地需要上传的目录 以及远程服务器的目录
def localDir = "${WORKSPACE}/h5_vip/test_dir/"
def vip_host = '152.22.3.186'
def vip_remote_dir = "/mnt/mall/h5"
def git_url="http://152.22.3.186:8081/mall/h5.git"
def git_auth = "12312312-f199-4b15-b087-123123"
def git_branch = "${branch}"
def project_env = "${project_env}"
def data_dir = "/mnt/mall/h5/h5_vip"
// 本地需要上传的目录 以及远程服务器的目录
def localDir = "${WORKSPACE}/h5_vip/test_dir/"
def vip_host = '152.22.3.186'
def vip_remote_dir = "/mnt/mall/h5"
}
stages {
stage('Git Checkout'){
stage('Git Checkout') {
steps {
echo "🏆 WORKSPACE: 【${WORKSPACE}】"
echo "🎯 branch: 【${git_branch}】"
Expand All @@ -210,16 +218,15 @@ pipeline {
sh 'ls -la'
}
}
}
stage('Send Files') {
when {
expression {
currentBuild.result == null || currentBuild.result == 'SUCCESS'
}
}
steps {
steps {
sh 'pwd'
script{
script {
switch (project_env) {
case "vip":
sh '''
Expand Down Expand Up @@ -247,7 +254,6 @@ pipeline {
// sh "scp -r -o StrictHostKeyChecking=no -i /var/lib/jenkins/.ssh/id_rsa -P 22 '${WORKSPACE}/h5_vip/' '$i:${data_dir}'"
// }
break
}
}
}
Expand Down
Binary file added docs/jenkins/imgs/4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/jenkins/imgs/4-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9b1a441

Please sign in to comment.