基于npm打包h5项目
1、首先需要安装node.js和淘宝的cnpm
2、安装jenkins
3、打包配置步骤
基于参数的打包脚本:
rm -rf {JENKINS_HOME}/jobs/{JOB_NAME}/
cd ${WORKSPACE}
rm -rf ${WORKSPACE}/node_modules
cnpm install
npm run build
cd {JENKINS_HOME}/jobs/{JOB_NAME}
tar -czvf {JOB_NAME}.tar.gz -C {WORKSPACE}/dist .
mv {JENKINS_HOME}/jobs/{JOB_NAME}/{JOB_NAME}.tar.gz {WORKSPACE}/build
没有参数化的打包脚本:
rm -rf /usr/local/jenkins/jenkinsData/jobs/h5Test/h5Test.tar.gz
cd /usr/local/jenkins/jenkinsData/workspace/h5Test
npm install
npm run build
cd /usr/local/jenkins/jenkinsData/jobs/h5Test
tar -zcvf h5Test.tar.gz -C /usr/local/jenkins/jenkinsData/workspace/h5Test/dist .
mv /usr/local/jenkins/jenkinsData/jobs/h5Test/h5Test.tar.gz /usr/local/jenkins/jenkinsData/workspace/h5Test/build
苹果系统搭建步骤:
原文地址:https://segmentfault.com/a/1190000010154974
代码语言:javascript复制1. 安装nodejs(已有则忽略)
brew install node
2. 搭建Jenkins环境
安装: brew install jenkins
启动: jenkins
默认:127.0.0.1:8080
安装系统常用插件。
PS: 首次启动遇到Unlock jenkins, 打开这个文件/Users/xxx/.jenkins/secrets/initialAdminPassword,密钥复制出来,填写就OK。2. 安装ssh插件 1. Publish Over SSH (文件发送到远程服务器) 2. SSH plugin (远程执行shell) 4. 新建项目
git地址,分支名
**增加构建步骤:** 5. Jenkins打包(Execute shell)
rm -rf /Users/xxx/.jenkins/jobs/test_jenkins/react_demo.tar.gz
npm install
npm run build
cd /Users/xxx/.jenkins/jobs/test_jenkins
tar -zcvf react_demo.tar.gz -C /Users/xxx/.jenkins/workspace/test_jenkins/dist/ .
mv /Users/xxx/.jenkins/jobs/test_jenkins/react_demo.tar.gz /Users/xxx/.jenkins/workspace/test_jenkins/
6. 发送文件(Send files or execute commands over SSH)
选择配置的ssh服务器,然后输入打包后的tar.gz,以及目标服务器的文件夹7. 远程执行脚本(Execute shell script on remote host using ssh)
首先选择配置的远程服务器
cd /root/react
tar -xzvf react_demo.tar.gz
rm -rf react_demo.tar.gz
还有比如重启tomcat或者ngix的shell