support plugin dockerfile username and password

This commit is contained in:
fanyangyang 2020-04-23 14:57:57 +08:00
parent d4a45dd9d1
commit b1e208b5f8
4 changed files with 13 additions and 1 deletions

View File

@ -310,6 +310,8 @@ func (p *PluginAction) buildPlugin(b *api_model.BuildPluginStruct, plugin *dbmod
ImageInfo: b.Body.ImageInfo,
Repo: b.Body.RepoURL,
GitURL: plugin.GitURL,
GitUsername: b.Body.Username,
GitPassword: b.Body.Password,
}
taskType := "plugin_image_build"
if plugin.BuildModel == "dockerfile" {

View File

@ -218,6 +218,14 @@ type BuildPluginStruct struct {
// in: body
// required: false
RepoURL string `json:"repo_url" validate:"repo_url"`
// git 账户名
// in: body
// required: false
Username string `json:"username"`
// git 密码
// in: body
// required: false
Password string `json:"password"`
// 版本信息, 协助选择插件版本
// in:body
// required: true

View File

@ -90,7 +90,7 @@ func (e *exectorManager) runD(t *model.BuildPluginTaskBody, logger event.Logger)
if err := util.CheckAndCreateDir(sourceDir); err != nil {
return err
}
if _, err := sources.GitClone(sources.CodeSourceInfo{RepositoryURL: t.GitURL, Branch: t.Repo}, sourceDir, logger, 4); err != nil {
if _, err := sources.GitClone(sources.CodeSourceInfo{RepositoryURL: t.GitURL, Branch: t.Repo, User: t.GitUsername, Password: t.GitPassword}, sourceDir, logger, 4); err != nil {
logger.Error("拉取代码失败", map[string]string{"step": "builder-exector", "status": "failure"})
logrus.Errorf("[plugin]git clone code error %v", err)
return err

View File

@ -26,6 +26,8 @@ type BuildPluginTaskBody struct {
Operator string `json:"operator"`
Repo string `json:"repo"`
GitURL string `json:"git_url"`
GitUsername string `json:"git_username"`
GitPassword string `json:"git_password"`
ImageURL string `json:"image_url"`
EventID string `json:"event_id"`
DeployVersion string `json:"deploy_version"`