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.
|
|
|
var express = require('express');
|
|
|
|
var router = express.Router();
|
|
|
|
//web钩子事件
|
|
|
|
//git@gogs.kirito.cool:panqihua/RiskCloudMock.git push事件
|
|
|
|
const {spawn} = require('child_process');
|
|
|
|
router.post('/server', function(req, res, next) {
|
|
|
|
|
|
|
|
const updated_at=req.body.repository.updated_at
|
|
|
|
|
|
|
|
console.info('调用自动部署命令')
|
|
|
|
|
|
|
|
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)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
res.json({message:`仓库代码${req.body.repository.ssh_url}部署中`})
|
|
|
|
});
|
|
|
|
|
|
|
|
//部署完毕事件
|
|
|
|
router.get('/finsh', function(req, res, next) {
|
|
|
|
console.info(`仓库代码${req.query.name}部署成功`)
|
|
|
|
res.json({message:`仓库代码${req.query.name}部署成功`})
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = router;
|