|
|
@@ -5,7 +5,6 @@ import cn.reghao.devops.mgr.ops.builder.model.po.AppBuilding;
|
|
|
import cn.reghao.devops.mgr.ops.app.model.po.AppConfig;
|
|
|
import cn.reghao.devops.mgr.ops.builder.model.LocalBuildDir;
|
|
|
import cn.reghao.devops.mgr.ops.builder.tool.repo.CommitInfo;
|
|
|
-import cn.reghao.devops.mgr.ops.build.model.po.DockerRegistry;
|
|
|
import lombok.Getter;
|
|
|
import lombok.Setter;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -38,7 +37,7 @@ public class PipelineContext implements AutoCloseable {
|
|
|
private String compileDir;
|
|
|
private String dockerfile;
|
|
|
private CommitInfo commitInfo;
|
|
|
- private DockerRegistry dockerRegistry;
|
|
|
+ private String dockerRegistry;
|
|
|
private String buildTargetPath;
|
|
|
|
|
|
// 构建日志
|
|
|
@@ -77,6 +76,22 @@ public class PipelineContext implements AutoCloseable {
|
|
|
return gitUrl.substring(lastIndex+1).split(".git")[0];
|
|
|
}
|
|
|
|
|
|
+ public String getRepoTag() {
|
|
|
+ String repoTag = String.format("%s:%s", appId, commitInfo.getCommitId());
|
|
|
+ if (dockerRegistry != null) {
|
|
|
+ repoTag = String.format("%s:%s", dockerRegistry, repoTag);
|
|
|
+ repoTag = simplifyPath(repoTag);
|
|
|
+ }
|
|
|
+ return repoTag;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String simplifyPath(String path) {
|
|
|
+ if (path == null) return null;
|
|
|
+ // 将两个及以上的斜杠替换为单个斜杠
|
|
|
+ // 但要小心不要误伤协议头(如 http://)
|
|
|
+ return path.replaceAll("(?<!:)/{2,}", "/");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 更新或创建阶段状态
|
|
|
*/
|