栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

自动化,压缩前端工程代码使用ftp上传到服务器,ssh登录服务器,解压上传的压缩代码

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

自动化,压缩前端工程代码使用ftp上传到服务器,ssh登录服务器,解压上传的压缩代码

接口:

//上传代码到目标服务器
const uploadCode = (req, res) => {
  const { buildPath, targetPath } = req.body
  const buildBat = 
`
echo unzip start
cd /temp/zip
7z x /temp/zip/build.tar -o/temp/unzip -y
xcopy \temp\unzip\build ${targetPath} /Y /E
echo success
`

  //创建用于解压的批处理文件
  fs.writeFileSync('/temp/zip/build.bat', buildBat, { encoding: 'utf8' }, (err) => {})
  //上传build压缩包到服务器
  spawn.sync(`./light/jenkins/upload.bat ${buildPath} ${targetPath}`, [], {
    stdio: 'inherit'
  })

  res.send({
    state: 1,
    data: {
      buildPath,
      targetPath
    },
    message: '成功'
  })
}

upload.bat:

echo %0 %1 %2
7z.exe a tempzipbuild.tar %1
ftp -s:C:ftpupload.ftp
ssh Administrator@39.97.238.175 "cd tempzip && ls && call .build.bat"

upload.ftp:

open www.xutongbao.top
root
您的密码
cd tempzip
put tempzipbuild.tar
put tempzipbuild.bat
ls
bye

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/468380.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号