提交 bd71a4ab 编写于 作者: C colynn.liu

feat(Done): jnlp agent change to native agent

上级 a7ffee68
......@@ -203,7 +203,7 @@ func (p *IntegrateController) DeleteIntegrateSetting() {
// GetCompileEnvs ..
func (p *IntegrateController) GetCompileEnvs() {
pm := settings.NewSettingManager()
rsp, err := pm.GetCompileEnvs("")
rsp, err := pm.GetCompileEnvs()
if err != nil {
p.HandleInternalServerError(err.Error())
log.Log.Error("Get compile envs occur error: %s", err.Error())
......
......@@ -1157,7 +1157,7 @@ func (pm *PipelineManager) renderHealthCheckCommand(projectID, stageID, publishJ
}
item := &jenkins.StepItem{}
item.Name = app.Name
// TODO: wip split healthcheck, use checkout container name tmp.
// TODO: refactor(WIP) healthcheck stage, use checkout container name tmp.
item.ContainerName = constant.CheckoutContainerName
appArrange, err := pm.appHandler.GetRealArrange(app.ID, stageID)
......
......@@ -34,8 +34,8 @@ type CompileEnvReq struct {
}
// GetCompileEnvs ..
func (pm *SettingManager) GetCompileEnvs(integrateType string) ([]*models.CompileEnv, error) {
items, err := pm.model.GetCompileEnvs(integrateType)
func (pm *SettingManager) GetCompileEnvs() ([]*models.CompileEnv, error) {
items, err := pm.model.GetCompileEnvs()
if err != nil {
log.Log.Error("get interate settings error: %s", err.Error())
return nil, err
......
......@@ -146,12 +146,10 @@ func (model *SysSettingModel) GetCompileEnvByName(compileEnvItem string) (*model
}
// GetCompileEnvs ...
func (model *SysSettingModel) GetCompileEnvs(integrateType string) ([]*models.CompileEnv, error) {
func (model *SysSettingModel) GetCompileEnvs() ([]*models.CompileEnv, error) {
integrateSettings := []*models.CompileEnv{}
qs := model.ormer.QueryTable(model.CompileEnvTableName).Filter("deleted", false)
if integrateType != "" {
qs = qs.Filter("type", integrateType)
}
_, err := qs.All(&integrateSettings)
if err != nil {
return nil, err
......
......@@ -39,8 +39,33 @@ func (m Migration20220415) Upgrade(ormer orm.Ormer) error {
// init component
_ = initComponent()
compileEnvs := []settings.CompileEnvReq{
{
Name: "jnlp",
Image: "colynn/jenkins-jnlp-agent:latest",
Description: "",
},
{
Name: "kaniko",
Image: "colynn/kaniko-executor:debug",
Command: "/bin/sh -c",
Args: "cat",
},
{
Name: "node",
Image: "node:12.12-alpine",
Description: "nodejs编译环境",
},
{
Name: "maven",
Image: "maven:3.8.2-openjdk-8",
Command: "/bin/sh -c",
Args: "cat",
},
}
// init compile envs
_ = initCompileEnvs()
_ = initCompileEnvs(compileEnvs)
// init task tmpls
_ = initTaskTemplates()
......@@ -93,32 +118,7 @@ func initComponent() error {
return nil
}
var compileEnvs = []settings.CompileEnvReq{
{
Name: "jnlp",
Image: "colynn/jenkins-jnlp-agent:latest",
Description: "",
},
{
Name: "kaniko",
Image: "colynn/kaniko-executor:debug",
Command: "/bin/sh -c",
Args: "cat",
},
{
Name: "node",
Image: "node:12.12-alpine",
Description: "nodejs编译环境",
},
{
Name: "maven",
Image: "maven:3.8.2-openjdk-8",
Command: "/bin/sh -c",
Args: "cat",
},
}
func initCompileEnvs() error {
func initCompileEnvs(compileEnvs []settings.CompileEnvReq) error {
settingModel := dao.NewSysSettingModel()
for _, item := range compileEnvs {
_, err := settingModel.GetCompileEnvByName(item.Name)
......
/*
Copyright 2021 The AtomCI Group Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package migrations
import (
"time"
"github.com/astaxie/beego/orm"
"github.com/go-atomci/atomci/internal/core/settings"
)
type Migration20230703 struct {
}
func (m Migration20230703) GetCreateAt() time.Time {
return time.Date(2023, 7, 03, 0, 0, 0, 0, time.Local)
}
func (m Migration20230703) Upgrade(ormer orm.Ormer) error {
addedCompileEnvs := []settings.CompileEnvReq{
{
Name: "checkout",
Image: "colynn/checkout:latest",
Description: "代码检出",
},
}
// init compile envs
_ = initCompileEnvs(addedCompileEnvs)
// update origin jnlp image
return updateCompileEnvs(ormer)
}
func updateCompileEnvs(ormer orm.Ormer) error {
_, err := ormer.Raw("UPDATE `sys_compile_env` SET `image`='jenkins/inbound-agent:latest' WHERE `name`='jnlp';").Exec()
if err != nil {
return err
}
return nil
}
......@@ -56,6 +56,7 @@ func initMigration() {
new(Migration20220324),
new(Migration20220414),
new(Migration20220415),
new(Migration20230703),
}
migrateInTx(migrationTypes)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册