未验证 提交 bd711359 编写于 作者: C colynn.liu 提交者: GitHub

Merge pull request #155 from colynn/feat-152-image-tag-tunning

feat: branch verify and message z-index updated
...@@ -99,8 +99,8 @@ func (manager *AppManager) SetArrange( ...@@ -99,8 +99,8 @@ func (manager *AppManager) SetArrange(
return err return err
} }
log.Log.Debug("update app arrnage item id: %v", id) log.Log.Debug("update app arrnage item id: %v", id)
//
validItemIDs := []int64{} validItemIDs := []int64{}
// TODO: add verify, one arrange only support add one image mapping item.
for _, imageMappingitem := range request.ImageMapings { for _, imageMappingitem := range request.ImageMapings {
if imageMappingitem.ProjectAppID == 0 { if imageMappingitem.ProjectAppID == 0 {
log.Log.Debug("item: %v did not join with project app: 0, skip", imageMappingitem.Name) log.Log.Debug("item: %v did not join with project app: 0, skip", imageMappingitem.Name)
......
...@@ -71,43 +71,6 @@ type DeployStepReq struct { ...@@ -71,43 +71,6 @@ type DeployStepReq struct {
Apps []*RunDeployAppReq `json:"apps"` Apps []*RunDeployAppReq `json:"apps"`
} }
//PublishApplyStepReq publish apply request
type PublishApplyStepReq struct {
Approver string `json:"approver"`
Message string `json:"message"`
}
// PublishStepReq pipeline run publish
type PublishStepReq struct {
ActionName string `json:"action_name"`
Apps []*RunPublishAppReq `json:"apps"`
EnableSwitchBranch bool `json:"enable_switch_branch"`
}
// BaseStepReq [Verify Step]..
type BaseStepReq struct {
Status string `json:"status"`
}
// PublishAuditStepReq ..
type PublishAuditStepReq struct {
BaseStepReq
Message string `json:"message"`
}
// RunPublishAppReq .
type RunPublishAppReq struct {
AutoMerge bool `json:"auto_merge"`
Branch string `json:"branch_name"`
Gray bool `json:"gray"`
ImageVersion string `json:"image_version"`
Jacoco bool `json:"jacoco"`
ProjectAppID int64 `json:"project_app_id"`
StaticCheck bool `json:"static_check"`
TargetBranch string `json:"target_branch"`
UnitTest bool `json:"unit_test"`
}
// WeeklyDenyList .. // WeeklyDenyList ..
type WeeklyDenyList []*struct { type WeeklyDenyList []*struct {
StartTime string `json:"start_time"` StartTime string `json:"start_time"`
...@@ -323,14 +286,6 @@ type AppParamsForHealthCheck struct { ...@@ -323,14 +286,6 @@ type AppParamsForHealthCheck struct {
FullName string `json:"full_name"` FullName string `json:"full_name"`
} }
// RunPublishAllParms there are all apps parms for jenkins pipeline job
type RunPublishAllParms struct {
*models.ProjectApp
*RunPublishAppReq
Release string `json:"release"`
MergeBranch bool `json:"merge-branch"`
}
// PublishJobBuildResult .. // PublishJobBuildResult ..
type PublishJobBuildResult struct { type PublishJobBuildResult struct {
AppID string `json:"app_id"` AppID string `json:"app_id"`
......
...@@ -579,49 +579,20 @@ func (pm *PipelineManager) renderTemplateStr(apps []*RunDeployAppReq, publishID, ...@@ -579,49 +579,20 @@ func (pm *PipelineManager) renderTemplateStr(apps []*RunDeployAppReq, publishID,
log.Log.Error("get app id: %v env id: %v real arrange, occur error: %s", item.ProjectAppID, envID, err.Error()) log.Log.Error("get app id: %v env id: %v real arrange, occur error: %s", item.ProjectAppID, envID, err.Error())
continue continue
} }
// TODO: write continue
imageMappings, err := pm.modelAppArrange.GetAppImageMappingByArrangeID(arrange.ID) // replace template str
arrangeConfig := arrange.Config
publishApp, err := pm.modelPublish.GetPublishAppByPublishIDAndAppID(publishID, item.ProjectAppID)
if err != nil { if err != nil {
log.Log.Error("get imagemapping error: %s", err.Error()) logs.Warn("when get publish app by publishid/appid occur error:%s, did not update app arrange image info", err.Error())
continue continue
} }
// replace template str
arrangeConfig := arrange.Config
var newImageAddr string
for _, image := range imageMappings {
switch image.ImageTagType {
// TODO: multiple imageTagType, code combine
case models.SystemDefaultTag:
publishApp, err := pm.modelPublish.GetPublishAppByPublishIDAndAppID(publishID, item.ProjectAppID)
if err != nil {
logs.Warn("when get publish app by publishid/appid occur error:%s, did not update app arrange image info", err.Error())
continue
}
imageTag, err := pm.getAppCodeCommitByBranch(item.ProjectAppID, publishApp.BranchName)
if err != nil {
logs.Warn("when get app code commit by branch error: %s, did not update app arrange image info", err.Error())
continue
}
originImageSplit := strings.Split(image.Image, ":") newImageAddr, originImage, err := pm.generateImageAddr(arrange.ID, item.ProjectAppID, publishApp.BranchName)
imageStr := image.Image if err != nil {
if len(originImageSplit) == 2 { continue
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, imageTag)
arrangeConfig = strings.Replace(arrangeConfig, image.Image, newImageAddr, -1)
case models.LatestTag:
originImageSplit := strings.Split(image.Image, ":")
imageStr := image.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, "latest")
arrangeConfig = strings.Replace(arrangeConfig, image.Image, newImageAddr, -1)
case models.OriginTag:
log.Log.Debug("image tag use from yaml, no need replace")
}
} }
arrangeConfig = strings.Replace(arrangeConfig, originImage, newImageAddr, -1)
if templateStr == "" { if templateStr == "" {
templateStr = arrangeConfig templateStr = arrangeConfig
} else { } else {
...@@ -631,7 +602,42 @@ func (pm *PipelineManager) renderTemplateStr(apps []*RunDeployAppReq, publishID, ...@@ -631,7 +602,42 @@ func (pm *PipelineManager) renderTemplateStr(apps []*RunDeployAppReq, publishID,
return templateStr, nil return templateStr, nil
} }
func (pm *PipelineManager) getAppCodeCommitByBranch(appID int64, branchName string) (string, error) { func (pm *PipelineManager) generateImageAddr(arrangeID, projectAppID int64, branch string) (string, string, error) {
imageMapping, err := pm.modelAppArrange.GetAppImageMappingByArrangeIDAndProjectAppID(arrangeID, projectAppID)
if err != nil {
log.Log.Error("get imagemapping error: %s", err.Error())
return "", "", err
}
newImageAddr := imageMapping.Image
switch imageMapping.ImageTagType {
case models.SystemDefaultTag:
// branch get from RunBuildAppReq.Branch
imageTag, err := pm.GetAppCodeCommitByBranch(projectAppID, branch)
if err != nil {
logs.Error("when get app code commit by branch error: %s, did not update app arrange image info", err.Error())
return "", "", err
}
originImageSplit := strings.Split(imageMapping.Image, ":")
imageStr := imageMapping.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, imageTag)
case models.LatestTag:
originImageSplit := strings.Split(imageMapping.Image, ":")
imageStr := imageMapping.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, "latest")
case models.OriginTag:
log.Log.Debug("image tag use from yaml, no need replace")
}
return newImageAddr, imageMapping.Image, nil
}
func (pm *PipelineManager) GetAppCodeCommitByBranch(appID int64, branchName string) (string, error) {
projectApp, err := pm.modelProject.GetProjectApp(appID) projectApp, err := pm.modelProject.GetProjectApp(appID)
if err != nil { if err != nil {
log.Log.Error("when get app code commit, get project ap by id: %v error:%s", appID, err.Error()) log.Log.Error("when get app code commit, get project ap by id: %v error:%s", appID, err.Error())
...@@ -666,8 +672,8 @@ func (pm *PipelineManager) getAppCodeCommitByBranch(appID int64, branchName stri ...@@ -666,8 +672,8 @@ func (pm *PipelineManager) getAppCodeCommitByBranch(appID int64, branchName stri
if len(got) > 0 { if len(got) > 0 {
return branchName + "-" + got[0].Sha[0:7], nil return branchName + "-" + got[0].Sha[0:7], nil
} else { } else {
logs.Warn("branch: %v did not include any commit, use latest tag", branchName) logs.Warn("branch: %v did not include any commit", branchName)
return branchName + "-latest", nil return "", fmt.Errorf("应用:%v 分支:%v 未包含任何提交, 请通过“我的应用”-“应用详情”-“同步远程分支”后重新选择", scmApp.Name, branchName)
} }
} }
...@@ -943,43 +949,16 @@ func (pm *PipelineManager) aggregateAppsParamsForDeploy(publishID, stageID int64 ...@@ -943,43 +949,16 @@ func (pm *PipelineManager) aggregateAppsParamsForDeploy(publishID, stageID int64
continue continue
} }
imageMapping, err := pm.modelAppArrange.GetAppImageMappingByArrangeIDAndProjectAppID(arrange.ID, app.ProjectAppID) publishApp, err := pm.modelPublish.GetPublishAppByPublishIDAndAppID(publishID, app.ProjectAppID)
if err != nil { if err != nil {
log.Log.Error("get imagemapping error: %s", err.Error()) logs.Warn("when get publish app by publishid/appid occur error:%s, did not update app arrange image info", err.Error())
continue continue
} }
newImageAddr := imageMapping.Image newImageAddr, _, err := pm.generateImageAddr(arrange.ID, app.ProjectAppID, publishApp.BranchName)
switch imageMapping.ImageTagType { if err != nil {
case models.SystemDefaultTag: continue
publishApp, err := pm.modelPublish.GetPublishAppByPublishIDAndAppID(publishID, app.ProjectAppID)
if err != nil {
logs.Warn("when get publish app by publishid/appid occur error:%s, did not update app arrange image info", err.Error())
continue
}
imageTag, err := pm.getAppCodeCommitByBranch(app.ProjectAppID, publishApp.BranchName)
if err != nil {
logs.Warn("when get app code commit by branch error: %s, did not update app arrange image info", err.Error())
continue
}
originImageSplit := strings.Split(imageMapping.Image, ":")
imageStr := imageMapping.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, imageTag)
case models.LatestTag:
originImageSplit := strings.Split(imageMapping.Image, ":")
imageStr := imageMapping.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, "latest")
case models.OriginTag:
log.Log.Debug("image tag use from yaml, no need replace")
} }
log.Log.Debug("imageAddr: %s", newImageAddr) log.Log.Debug("imageAddr: %s", newImageAddr)
allParm := &RunDeployAllParms{ allParm := &RunDeployAllParms{
ProjectID: projectApp.ProjectID, ProjectID: projectApp.ProjectID,
...@@ -988,7 +967,6 @@ func (pm *PipelineManager) aggregateAppsParamsForDeploy(publishID, stageID int64 ...@@ -988,7 +967,6 @@ func (pm *PipelineManager) aggregateAppsParamsForDeploy(publishID, stageID int64
ImageAddr: newImageAddr, ImageAddr: newImageAddr,
} }
allParms = append(allParms, allParm) allParms = append(allParms, allParm)
} }
return allParms, nil return allParms, nil
} }
...@@ -1101,44 +1079,10 @@ func (pm *PipelineManager) renderAppImageitemsForBuild(projectID, publishID, sta ...@@ -1101,44 +1079,10 @@ func (pm *PipelineManager) renderAppImageitemsForBuild(projectID, publishID, sta
continue continue
} }
imageMapping, err := pm.modelAppArrange.GetAppImageMappingByArrangeIDAndProjectAppID(arrange.ID, app.ProjectAppID) imageURL, _, err := pm.generateImageAddr(arrange.ID, app.ProjectAppID, app.Branch)
if err != nil { if err != nil {
log.Log.Error("get imagemapping error: %s", err.Error())
continue continue
} }
newImageAddr := imageMapping.Image
switch imageMapping.ImageTagType {
case models.SystemDefaultTag:
publishApp, err := pm.modelPublish.GetPublishAppByPublishIDAndAppID(publishID, app.ProjectAppID)
if err != nil {
logs.Warn("when get publish app by publishid/appid occur error:%s, did not update app arrange image info", err.Error())
continue
}
imageTag, err := pm.getAppCodeCommitByBranch(app.ProjectAppID, publishApp.BranchName)
if err != nil {
logs.Warn("when get app code commit by branch error: %s, did not update app arrange image info", err.Error())
continue
}
originImageSplit := strings.Split(imageMapping.Image, ":")
imageStr := imageMapping.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, imageTag)
case models.LatestTag:
originImageSplit := strings.Split(imageMapping.Image, ":")
imageStr := imageMapping.Image
if len(originImageSplit) == 2 {
imageStr = originImageSplit[0]
}
newImageAddr = fmt.Sprintf("%s:%s", imageStr, "latest")
case models.OriginTag:
log.Log.Debug("image tag use from yaml, no need replace")
}
imageURL := newImageAddr
dockerfile := app.Dockerfile dockerfile := app.Dockerfile
if dockerfile == "" { if dockerfile == "" {
dockerfile = "Dockerfile" dockerfile = "Dockerfile"
......
...@@ -18,6 +18,7 @@ package publish ...@@ -18,6 +18,7 @@ package publish
import ( import (
"fmt" "fmt"
"strings"
"github.com/go-atomci/atomci/internal/core/pipelinemgr" "github.com/go-atomci/atomci/internal/core/pipelinemgr"
"github.com/go-atomci/atomci/internal/middleware/log" "github.com/go-atomci/atomci/internal/middleware/log"
...@@ -314,15 +315,28 @@ func (pm *PublishManager) createPublishOperationLogItem(co *CreateOperationLogRe ...@@ -314,15 +315,28 @@ func (pm *PublishManager) createPublishOperationLogItem(co *CreateOperationLogRe
func (pm *PublishManager) publishCreateParamVerify(req *PublishReq) error { func (pm *PublishManager) publishCreateParamVerify(req *PublishReq) error {
// name // name
if len(req.Name) > 64 { if len(req.Name) > 64 {
return fmt.Errorf("版本名称过长,不允许超过64个字符") return fmt.Errorf("流水线描述过长,不允许超过64个字符")
} }
// VersionNo // VersionNo
if len(req.VersionNo) > 64 { if len(req.VersionNo) > 64 {
return fmt.Errorf("版本号不允许超过16个字符") return fmt.Errorf("流水线名称不允许超过64个字符")
} }
// App // App
if len(req.Apps) == 0 { if len(req.Apps) == 0 {
return fmt.Errorf("请至少勾选一个代码库后,重试") return fmt.Errorf("请至少勾选一个代码库后,重试")
} }
errs := []string{}
for _, app := range req.Apps {
if app.BranchName == "" {
errs = []string{"请确认分支选择"}
}
_, err := pm.pipelineHandler.GetAppCodeCommitByBranch(app.AppID, app.BranchName)
if err != nil {
errs = append(errs, err.Error())
}
}
if len(errs) > 0 {
return fmt.Errorf("%v", strings.Join(errs, ","))
}
return nil return nil
} }
.text {
font: 16px/24px;
}
.clearfix:before,
.clearfix:after {
display: table;
content: "";
}
.clearfix:after {
clear: both
}
#nav .box-card {
color: #606266;
width: 23.7%;
height: 60px;
float: left;
margin-left: 1%;
margin-bottom: 1%;
box-shadow: 0 1px 10px 0 rgba(50, 50, 50, 0);
}
#nav {
text-align:center;
}
#nav span{
color: #13ce66
}
#bnav span{
color: #13ce66
}
#bnav {
text-align:center;
}
#bnav .box-card {
color: #606266;
width: 32%;
height: 60px;
float: left;
margin-left:1%;
box-shadow: 0 1px 10px 0 rgba(50, 50, 50, 0);
}
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
.el-row{ .el-row{
text-align: left; text-align: left;
} }
/* 更加突显的外发光效果 */ /* 更加突显的外发光效果 */
/* .el-button--default:focus, .el-button--default:hover, /* .el-button--default:focus, .el-button--default:hover,
......
...@@ -287,7 +287,6 @@ ...@@ -287,7 +287,6 @@
}, },
methods: { methods: {
tabClick(val) { tabClick(val) {
console.info(val.name);
this.activeName = val.name; this.activeName = val.name;
this.getList(); this.getList();
}, },
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
:visible.sync="dialogFormVisible" :visible.sync="dialogFormVisible"
class="arrangement" class="arrangement"
size="40%" size="40%"
z-index="1100"
:before-close="handleClose" :before-close="handleClose"
> >
<div class="arrange-body"> <div class="arrange-body">
......
<template> <template>
<el-dialog top='25vh' :close-on-click-modal="false" :visible.sync="dialogFormVisible" class="createDialog" :before-close="doCancelCreate"> <el-dialog top='25vh' z-index="1100" :close-on-click-modal="false" :visible.sync="dialogFormVisible" class="createDialog" :before-close="doCancelCreate">
<el-form ref="ruleForm" :model="form" :rules="rules"> <el-form ref="ruleForm" :model="form" :rules="rules">
<el-form-item :label="$t('bm.add.backStage')" prop="stage"> <el-form-item :label="$t('bm.add.backStage')" prop="stage">
<el-select v-model="form.stage" :placeholder="$t('bm.add.select')" filterable> <el-select v-model="form.stage" :placeholder="$t('bm.add.select')" filterable>
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
} }
</style> </style>
<template> <template>
<el-dialog top='15vh' v-if="dialogFormVisible" :close-on-click-modal="false" :show-close="false" width='70%' :title="username" <el-dialog top='15vh' z-index="1100" v-if="dialogFormVisible" :close-on-click-modal="false" :show-close="false" width='70%' :title="username"
:visible.sync="dialogFormVisible" class="commonDialog projectPubModuleList"> :visible.sync="dialogFormVisible" class="commonDialog projectPubModuleList">
<div> <div>
<i id="color" class="el-icon-close" @click="handleClose" style="cursor:pointer;position:absolute;right:15px;top:15px;"></i> <i id="color" class="el-icon-close" @click="handleClose" style="cursor:pointer;position:absolute;right:15px;top:15px;"></i>
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<el-table-column prop="build_path" label="构建目录" sortable min-width="10%" :show-overflow-tooltip="true" /> <el-table-column prop="build_path" label="构建目录" sortable min-width="10%" :show-overflow-tooltip="true" />
<el-table-column :label="$t('bm.deployCenter.releaseBran')" min-width="15%"> <el-table-column :label="$t('bm.deployCenter.releaseBran')" min-width="15%">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model.trim="scope.row.branch_name" filterable :placeholder="$t('bm.add.selectSubmitBra')"> <el-select v-model.trim="scope.row.branch_name" filterable :placeholder="$t('bm.add.selectSubmitBra')" disabled>
<el-option v-for="(item, index) in scope.row.branch_history_list" :key="index" :label="item" :value="item"> <el-option v-for="(item, index) in scope.row.branch_history_list" :key="index" :label="item" :value="item">
</el-option> </el-option>
</el-select> </el-select>
...@@ -99,8 +99,6 @@ ...@@ -99,8 +99,6 @@
props: ['listData', 'pubType', 'cpData'], props: ['listData', 'pubType', 'cpData'],
data() { data() {
return { return {
// 是否启用切换分支
enable_switch_branch: true,
username: '', username: '',
envStageID: '', envStageID: '',
publishid: '', publishid: '',
...@@ -203,7 +201,6 @@ ...@@ -203,7 +201,6 @@
}, },
doShows(publishid, envStageID, step) { doShows(publishid, envStageID, step) {
this.selectList = []; this.selectList = [];
this.enable_switch_branch = true;
this.tableList = []; this.tableList = [];
this.cpList = []; this.cpList = [];
this.username = step; this.username = step;
......
<template> <template>
<el-dialog top='15vh' v-if="dialogFormVisible" :close-on-click-modal="false" width='65%' :title="title" <el-dialog z-index="1100" top='15vh' v-if="dialogFormVisible" :close-on-click-modal="false" width='65%' :title="title"
:visible.sync="dialogFormVisible" class="createDialog"> :visible.sync="dialogFormVisible" class="createDialog">
<el-table border :data="dataList" @select-all="handleSelectAll" @select='handleSelect' ref="appDeploy"> <el-table border :data="dataList" @select-all="handleSelectAll" @select='handleSelect' ref="appDeploy">
<el-table-column type="selection" width="50" disabled='true' :show-overflow-tooltip=true /> <el-table-column type="selection" width="50" disabled='true' :show-overflow-tooltip=true />
......
<template> <template>
<el-dialog :close-on-click-modal="false" style="width:50%;margin-left:25%" top='25vh' :visible.sync="dialogFormVisible" class="createDialog" :before-close="doCancelCreate"> <el-dialog z-index="1100" :close-on-click-modal="false" style="width:50%;margin-left:25%" top='25vh' :visible.sync="dialogFormVisible" class="createDialog" :before-close="doCancelCreate">
<el-form> <el-form>
<el-form-item :label="$t('bm.add.nextStage')"> <el-form-item :label="$t('bm.add.nextStage')">
<el-select v-model="stage" :placeholder="$t('bm.add.select')" @change="change" filterable style="padding-bottom:20px"> <el-select v-model="stage" :placeholder="$t('bm.add.select')" @change="change" filterable style="padding-bottom:20px">
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
} }
</style> </style>
<template> <template>
<el-dialog top='15vh' v-if="dialogFormVisible" :close-on-click-modal="false" width='65%' :title="setname" :visible.sync="dialogFormVisible" class="createDialog"> <el-dialog z-index="1020" top='15vh' v-if="dialogFormVisible" :close-on-click-modal="false" width='65%' :title="setname" :visible.sync="dialogFormVisible" class="createDialog">
<el-form ref="ruleForm" :model="form" :rules="rules" label-width="52px"> <el-form ref="ruleForm" :model="form" :rules="rules" label-width="52px">
<div> <div>
<el-row> <el-row>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册