You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
riskcloudrun/routes/index.js

39 lines
1.1 KiB

4 years ago
var express = require('express');
var router = express.Router();
4 years ago
//web钩子事件
//git@gogs.kirito.cool:panqihua/RiskCloudMock.git push事件
4 years ago
const {spawn} = require('child_process');
4 years ago
router.post('/server', function(req, res, next) {
const updated_at=req.body.repository.updated_at
4 years ago
console.info('调用自动部署命令')
4 years ago
const promise = new Promise((resolve, reject) => {
const spawnObj = spawn('updateRisk', ['RiskCloudMock'], {encoding: 'utf-8'});
spawnObj.stdout.on('data', function(chunk) {
console.log(chunk.toString());
});
spawnObj.stderr.on('data', (data) => {
console.error(data);
});
spawnObj.on('close', function(code) {
console.log('close code : ' + code);
})
spawnObj.on('exit', (code) => {
console.log('exit code : ' + code);
resolve(true)
})
4 years ago
})
4 years ago
4 years ago
res.json({message:`仓库代码${req.body.repository.ssh_url}部署中`})
4 years ago
});
4 years ago
//部署完毕事件
4 years ago
router.get('/finsh', function(req, res, next) {
4 years ago
console.info(`仓库代码${req.query.name}部署成功`)
4 years ago
res.json({message:`仓库代码${req.query.name}部署成功`})
4 years ago
});
4 years ago
module.exports = router;