Commit 1bcdefb2 authored by 黎博's avatar 黎博

新增3个提供给jenkins的接口

parent 2ef7abea
......@@ -10,8 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
@CrossOrigin
@RestController
......@@ -138,4 +137,33 @@ public class DockerProjectController {
map.put("updatedAt", dockerProject.getUpdateTime());
return JsonResult.buildSuccessResult(map);
}
/**
* 给jenkins构建提供的项目列表接口
* @param type
* @return
*/
@GetMapping("/get_project_for_jenkins")
public String getProjectsForJenkins(@RequestParam String type) {
QueryWrapper<DockerProject> dockerProjectQueryWrapper = new QueryWrapper<>();
dockerProjectQueryWrapper.
eq("project_type", type).
eq("is_active", 1);
List<DockerProject> dockerProjectList = dockerProjectService.list(dockerProjectQueryWrapper);
List<String> resultList = new ArrayList<>();
for (DockerProject dockerProject: dockerProjectList) {
resultList.add(dockerProject.getProjectName());
}
resultList.sort(String::compareTo);
return String.join("\n", resultList);
}
@GetMapping("/get_git_path")
public String getGitPath(@RequestParam String projectName) {
QueryWrapper<DockerProject> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("project_name", projectName);
DockerProject dockerProject = dockerProjectService.getOne(queryWrapper);
return dockerProject.getGitPath();
}
}
......@@ -14,10 +14,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* k8及容器操作相关接口
......@@ -426,4 +423,20 @@ public class K8sController {
}
return JsonResult.buildSuccessResult(String.join(",", nsStrList));
}
/**
* 给jenkins构建提供的namespace列表
* @param env all、test、dev
* @return
*/
@GetMapping("/get_namespace_for_jenkins")
public String getNamespaceForJenkins(@RequestParam String env) {
List<Map> mapList = k8sService.getNamespaceList(env);
List<String> resultList = new ArrayList<>();
for (Map map: mapList) {
resultList.add(map.get("name").toString());
}
resultList.sort(String::compareTo);
return String.join("\n", resultList);
}
}
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