From 3b2f9048f17d1a93b898e30269f0f879fd82236f Mon Sep 17 00:00:00 2001
From: wangyilin <1454641981@qq.com>
Date: Thu, 31 Oct 2024 11:41:19 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4jenkins?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
securityManagement/Jenkinsfile | 46 +++++++++++++++++++++++++++
securityManagement/src/views/test.vue | 2 +-
2 files changed, 47 insertions(+), 1 deletion(-)
create mode 100644 securityManagement/Jenkinsfile
diff --git a/securityManagement/Jenkinsfile b/securityManagement/Jenkinsfile
new file mode 100644
index 0000000..e6640d3
--- /dev/null
+++ b/securityManagement/Jenkinsfile
@@ -0,0 +1,46 @@
+pipeline {
+ agent any
+ tools {
+ nodejs "node-v20.10.0"
+ }
+ stages {
+ stage('拉取代码') {
+ steps {
+ echo '开始拉取代码'
+ checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[credentialsId: '3', url: 'http://175.6.124.250:3100/luozhun/policeSecurity.git']])
+ echo '代码拉取成功'
+ }
+ }
+ stage('构建前端项目') {
+ steps{
+ echo '开始构建前端项目'
+ sh 'cd /var/jenkins_home/workspace/警保联动-保安后台/securityManagement && npm install --registry=https://registry.npmmirror.com && npm run build'
+ echo '前端项目构建完成'
+ }
+ }
+ stage('ssh远程推送代码'){
+ steps{
+ echo '开始推送构建产物'
+ script{
+ def remote = [:]
+ remote.name = 'server-118.253.177.137'
+ remote.host = '118.253.177.137'
+ remote.port = 55555
+ remote.allowAnyHosts = true
+ withCredentials([usernamePassword(credentialsId: '4', passwordVariable: 'password', usernameVariable: 'username')]) {
+ remote.user = "${username}"
+ remote.password = "${password}"
+ }
+ sshCommand remote: remote, command: 'pwd=$(pwd) echo "ssh连接成功!当前工作目录:$(pwd)"'
+ sshCommand remote: remote, command: 'echo "删除:securityManagement..."'
+ sshRemove remote: remote, path: '/home/app/apps/1panel/apps/openresty/openresty/www/sites/policeSecurityServer/index/securityManagement'
+ sshCommand remote: remote, command: 'echo "删除:superManagement成功!"'
+
+ sshCommand remote: remote, command: 'echo "将构建的securityManagement发送到服务器..."'
+ sshPut remote: remote, from: '/var/jenkins_home/workspace/警保联动-保安后台/securityManagement/securityManagement', into: '/home/app/apps/1panel/apps/openresty/openresty/www/sites/policeSecurityServer/index'
+ sshCommand remote: remote, command: 'echo "securityManagement发送成功!"'
+ }
+ }
+ }
+ }
+}
diff --git a/securityManagement/src/views/test.vue b/securityManagement/src/views/test.vue
index 39d9e87..4c3f614 100644
--- a/securityManagement/src/views/test.vue
+++ b/securityManagement/src/views/test.vue
@@ -1,5 +1,5 @@
- test
+ test00001