自动化,压缩前端工程代码使用ftp上传到服务器,ssh登录服务器,解压上传的压缩代码
  KvevbRuwqC1X 2023年11月02日 71 0

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

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

 

接口:

//上传代码到目标服务器
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 \temp\zip\build.tar %1
ftp -s:C:\ftp\upload.ftp
ssh Administrator@39.97.238.175 "cd \temp\zip && ls && call .\build.bat"

upload.ftp:

open www.xutongbao.top
root
您的密码
cd temp\zip
put \temp\zip\build.tar
put \temp\zip\build.bat
ls
bye


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  ehrZuhofWJiC   2024年05月17日   29   0   0 服务器linux
KvevbRuwqC1X