|
|
@@ -1,5 +1,6 @@
|
|
|
package cn.seecoder.web.core.pipeline.handler;
|
|
|
|
|
|
+import cn.seecoder.api.ApplicationProperties;
|
|
|
import cn.seecoder.api.docker.DockerApi;
|
|
|
import cn.seecoder.api.git.GitApi;
|
|
|
import cn.seecoder.common.util.SpringUtil;
|
|
|
@@ -34,12 +35,13 @@ import java.util.List;
|
|
|
@Slf4j
|
|
|
@Data
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
-public class SonarJavaImageBuildHandler extends AbstractHandler{
|
|
|
+public class SonarJavaImageBuildHandler extends AbstractHandler {
|
|
|
|
|
|
private final GitApi gitApi;
|
|
|
private final DockerApi dockerApi;
|
|
|
private final ProjectService projectService;
|
|
|
private final BranchService branchService;
|
|
|
+ private final ApplicationProperties applicationProperties;
|
|
|
|
|
|
// properties from pipeline config json
|
|
|
// private String repoUrl;
|
|
|
@@ -52,6 +54,7 @@ public class SonarJavaImageBuildHandler extends AbstractHandler{
|
|
|
this.dockerApi = SpringUtil.getBean(DockerApi.class);
|
|
|
this.projectService = SpringUtil.getBean(ProjectService.class);
|
|
|
this.branchService = SpringUtil.getBean(BranchService.class);
|
|
|
+ this.applicationProperties = SpringUtil.getBean(ApplicationProperties.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -73,6 +76,9 @@ public class SonarJavaImageBuildHandler extends AbstractHandler{
|
|
|
throw new PipelineException(HttpStatus.SC_SERVICE_UNAVAILABLE, PipelineException.BRANCH_NOT_FOUND_ERROR);
|
|
|
}
|
|
|
String commitHash = branch.getCommit().getId();
|
|
|
+ String projectKey = applicationProperties.getSonar().getProjectKey();
|
|
|
+ String loginToken = applicationProperties.getSonar().getLoginToken();
|
|
|
+ String sonarHost = applicationProperties.getSonar().getHost();
|
|
|
|
|
|
// 1. 有git从git拿到地址仓库
|
|
|
Path directory;
|
|
|
@@ -108,8 +114,11 @@ public class SonarJavaImageBuildHandler extends AbstractHandler{
|
|
|
line = line
|
|
|
.replace("%commitHash%", commitHash)
|
|
|
.replace("%projectId%", Integer.toString(projectId))
|
|
|
- .replace("%imageName%",imageName)
|
|
|
- .replace("%imageTag%", imageTag);
|
|
|
+ .replace("%imageName%", imageName)
|
|
|
+ .replace("%imageTag%", imageTag)
|
|
|
+ .replace("%projectKey%", projectKey)
|
|
|
+ .replace("%loginToken%", loginToken)
|
|
|
+ .replace("%host%", sonarHost);
|
|
|
|
|
|
sb.append(line).append("\n");
|
|
|
}
|