Commit d8ff13c1 authored by 黎博's avatar 黎博

新增jenkins构建接口

parent e6a66793
package cn.qg.holmes.controller.gitlab;
import cn.qg.holmes.common.JsonResult;
import cn.qg.holmes.utils.JenkinsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/jenkins")
public class JenkinsController {
@Autowired
JenkinsService jenkinsService;
/**
* 构建指定的jenkins job
* @param type 类型,java/ui/node
* @param project 项目名
* @param branch 分支名
* @param namespace 环境
* @return
*/
@GetMapping("/build")
public JsonResult buildSpecifiedJob(@RequestParam String type,
@RequestParam String project,
@RequestParam String branch,
@RequestParam String namespace) {
try {
log.info("开始构建jenkins项目:项目类型:{}, 项目名:{}, 分支:{}, 部署至环境:{}", type, project, branch, namespace);
jenkinsService.buildJenkinsJob(type, project, branch, namespace);
return JsonResult.buildSuccessResult(true);
} catch (Exception e) {
e.printStackTrace();
return JsonResult.buildErrorStateResult("构建失败!", false);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment