Skip to content

Commit

Permalink
fix: complice env choose bug
Browse files Browse the repository at this point in the history
  • Loading branch information
colynn committed May 22, 2022
1 parent de7ed1b commit 582a1e1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions constant/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ const (

var Integratetypes = []string{IntegrateKubernetes, IntegrateJenkins, IntegrateRegistry}
var ScmIntegratetypes = []string{SCMGitlab, SCMGithub, SCMGitea, SCMGitee, SCMGogs}

const (
DefaultContainerName = "jnlp"
BuildImageContainerName = "kaniko"
)
20 changes: 12 additions & 8 deletions internal/core/pipelinemgr/uitls.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ func (pm *PipelineManager) generateCompileEnvParams(apps []*RunBuildAppReq) []co
if err != nil {
logs.Warn("get compile env by id:%v error: %s", scmApp.CompileEnvID, err.Error())
}
if compileItem.Name == constant.DefaultContainerName {
log.Log.Warn("app: %v setup complie env to %v, skip this compileItem generate", constant.DefaultContainerName, scmApp.Name)
continue
}
compileEnvItem := compileEnv{
Image: compileItem.Image,
Args: compileItem.Args,
Expand Down Expand Up @@ -264,12 +268,12 @@ func (pm *PipelineManager) CreateBuildJob(creator string, projectID, publishID i
}
jobName := fmt.Sprintf("atomci_%v_%v_%v", projectID, publishID, envStageJSON.StageID)

jenkinsJNLPTemplate, err := pm.getSysDefaultCompileEnv("jnlp")
jenkinsJNLPTemplate, err := pm.getSysDefaultCompileEnv(constant.DefaultContainerName)
if err != nil {
log.Log.Error("when create build job, get sys default jnlp compile env error: %s", err.Error())
log.Log.Error("when create build job, get sys default %v compile env error: %s", constant.DefaultContainerName, err.Error())
return 0, "", err
}
jenkinsKanikoTemplate, err := pm.getSysDefaultCompileEnv("kaniko")
jenkinsKanikoTemplate, err := pm.getSysDefaultCompileEnv(constant.BuildImageContainerName)
if err != nil {
log.Log.Error("when create build job, get sys default kaniko compile env error: %s", err.Error())
return 0, "", err
Expand Down Expand Up @@ -531,9 +535,9 @@ func (pm *PipelineManager) CreateDeployJob(creator string, projectID, publishID
{Key: "USER_TOKEN", Value: userToken},
}

jenkinsJNLPTemplate, err := pm.getSysDefaultCompileEnv("jnlp")
jenkinsJNLPTemplate, err := pm.getSysDefaultCompileEnv(constant.DefaultContainerName)
if err != nil {
log.Log.Error("when create deploy job, get sys default jnlp compile env error: %s", err.Error())
log.Log.Error("when create deploy job, get sys default %v compile env error: %s", constant.DefaultContainerName, err.Error())
return 0, "", err
}

Expand Down Expand Up @@ -1035,17 +1039,17 @@ func (pm *PipelineManager) renderAppBuildItemsForBuild(projectID, stageID, publi
for _, app := range allParms {
item := &jenkins.StepItem{}
item.Name = app.Name
// Default containername is jnlp
item.ContainerName = strings.ToLower(app.Name)
// Default containername is constant.DefaultContainerName(jnlp)
item.ContainerName = constant.DefaultContainerName
command := fmt.Sprintf("sh 'echo app:%v language:%v, did not defined compile command, skip compile'", app.Name, app.Language)
customCompileCommand := app.RunBuildAppReq.CompileCommand

appPath := pm.generateAppPth(stageID, projectID, ciConfig[3], app)
appRootPath := appPath
if app.CompileEnvID == 0 {
item.ContainerName = "jnlp"
command = fmt.Sprintf("sh 'echo app:%v language:%v, did not setup compile env,skip compile...'", app.Name, app.Language)
} else if len(customCompileCommand) > 0 {
item.ContainerName = strings.ToLower(app.Name)
command = fmt.Sprintf("sh 'cd %v; %v'", appRootPath, customCompileCommand)
}
item.Command = command
Expand Down
2 changes: 2 additions & 0 deletions web/src/views/setting/components/CompileEnvCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ export default {
};
if (this.form.name == 'jnlp' || this.form.name == 'kaniko') {
this.systemReserved = true
} else {
this.systemReserved = false
}
this.rowId = item.id;
} else {
Expand Down

0 comments on commit 582a1e1

Please sign in to comment.