Jenkins配置vue前端项目(最简单的操作)

jenkins配置后端项目:https://blog.csdn.net/wujiangbo520/article/details/128602076

一,新建项目
二,配置git


bash 复制代码
@echo off
setlocal

set "APP_NAME=web_lumination"
set "JENKINS_WORKSPACE=C:\workSpace\jenkins\workspace"
set "NGINX_DIR=C:\Program Files\nginx-1.28.0"

echo Starting deployment for %APP_NAME%...

:: 项目构建部分
cd /d "%JENKINS_WORKSPACE%\%APP_NAME%"
call npm install
call npm run build:dev

:: 文件部署部分
set "TARGET_DIR=%NGINX_DIR%\html\%APP_NAME%"
if not exist "%TARGET_DIR%" mkdir "%TARGET_DIR%"
xcopy "dist\*" "%TARGET_DIR%\" /E /Y /I

echo Step 5: Managing Nginx service...
:: 使用更安全的方式重启 Nginx
cd /d "%NGINX_DIR%"

:: 检查 Nginx 是否在运行
tasklist /FI "IMAGENAME eq nginx.exe" 2>NUL | find /I /N "nginx.exe">NUL
if "%ERRORLEVEL%"=="0" (
    echo Nginx is running, sending reload signal...
    nginx -s reload
) else (
    echo Starting Nginx...
    nginx
)

echo.
echo ========================================
echo Deployment completed successfully!
echo ========================================

endlocal

nginx脚本:

XML 复制代码
server {
		listen       5173;
		server_name  localhost;
		
		# 你的 Vue 应用
		location /web_lumination {
			alias   "C:/Program Files/nginx-1.28.0/html/web_lumination";
			index  index.html;
			
			# 支持 Vue Router history 模式
			try_files $uri $uri/ /web_lumination/index.html;
		}
		
		# 可选:默认位置指向你的应用
		location / {
			root   "C:/Program Files/nginx-1.28.0/html/web_lumination";
			index  index.html;
			try_files $uri $uri/ /index.html;
		}
	}
三,执行构建---OKK
  1. 问题:

    中途遇到了很多问题,最后折腾出来的最简单操作

    ①首先git/nodejs先要安装好

    ②npm可能识别不了:

    1. 进入 ‌Jenkins → 系统管理 → 系统配置
    2. 找到"全局属性"部分,勾选"环境变量"
    3. 添加环境变量:
      • 名称:Path
      • 值:C:\Program Files\nodejs\;(根据实际安装路径调整)
相关推荐
Doris8937 分钟前
【 Vue】 Vue3全面讲解文档
前端·javascript·vue.js
玉梅小洋8 分钟前
Docker 镜像在节点间的高效拷贝的方案
运维·docker·容器
niceffking15 分钟前
Linux信号相关函数
linux·运维·服务器·linux信号
Hexene...18 分钟前
【前端Vue】如何快速直观地查看引入的前端依赖?名称版本、仓库地址、开源协议、作者、依赖介绍、关系树...(Node Modules Inspector)
前端·javascript·vue.js
蚰蜒螟18 分钟前
Linux 7 中的系统调用原理
linux·运维·服务器
fanruitian19 分钟前
div水平垂直居中
前端·javascript·html
Reuuse20 分钟前
【linux】进程间通信
linux·运维·服务器
旭久22 分钟前
react+antd实现一个支持多种类型及可新增编辑搜索的下拉框
前端·javascript·react.js
aesthetician33 分钟前
Spotify 网页版前端技术全面解析
前端
咩图33 分钟前
Sketchup软件二次开发+Ruby+VisualStudioCode
java·前端·ruby