Merge pull request #397 from GLYASAI/codebranch

[FIX] no branch for code info
This commit is contained in:
barnettZQG 2019-08-27 06:29:03 -05:00 committed by GitHub
commit d55c65cb07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 3 deletions

View File

@ -40,6 +40,7 @@ type BuildVersion struct {
Cmd string `json:"cmd"` //启动命令
RepoURL string `json:"repo_url"` // source image name or source code url
CodeBranch string `json:"code_branch"`
CodeVersion string `json:"code_version"`
CommitMsg string `json:"code_commit_msg"`
Author string `json:"code_commit_author"`

View File

@ -285,7 +285,7 @@ func (i *SourceCodeBuildItem) UpdateVersionInfo(vi *dbmodel.VersionInfo) error {
version.CommitMsg = vi.CommitMsg
version.Author = vi.Author
version.CodeVersion = vi.CodeVersion
logrus.Debugf("update app version %+v", *version)
version.CodeBranch = vi.CodeBranch
if err := db.GetManager().VersionInfoDao().UpdateModel(version); err != nil {
return err
}
@ -300,10 +300,11 @@ func (i *SourceCodeBuildItem) UpdateBuildVersionInfo(res *build.Response) error
EventID: i.EventID,
ImageName: builder.RUNNERIMAGENAME,
FinalStatus: "success",
CodeBranch: i.CodeSouceInfo.Branch,
CodeVersion: i.commit.Hash,
CommitMsg: i.commit.Message,
Author: i.commit.Author,
FinishTime: time.Now(), // TODO(huangrh 20190816): do it in dao
FinishTime: time.Now(),
}
if err := i.UpdateVersionInfo(vi); err != nil {
logrus.Errorf("update version info error: %s", err.Error())

View File

@ -299,6 +299,7 @@ func (e *exectorManager) buildFromSourceCode(task *pb.TaskMessage) {
vi := &dbmodel.VersionInfo{
FinalStatus: "failure",
EventID: i.EventID,
CodeBranch: i.CodeSouceInfo.Branch,
CodeVersion: i.commit.Hash,
CommitMsg: i.commit.Message,
Author: i.commit.Author,
@ -306,7 +307,7 @@ func (e *exectorManager) buildFromSourceCode(task *pb.TaskMessage) {
}
if err := i.UpdateVersionInfo(vi); err != nil {
logrus.Errorf("update version Info error: %s", err.Error())
// TODO(huangrh 20190816): use logger
i.Logger.Error(fmt.Sprintf("error updating version info: %v", err), event.GetCallbackLoggerOption())
}
} else {
var configs = make(map[string]string, len(i.Configs))

View File

@ -42,6 +42,7 @@ type VersionInfo struct {
Cmd string `gorm:"column:cmd;size:200" json:"cmd"` //启动命令
RepoURL string `gorm:"column:repo_url;size:100" json:"repo_url"`
CodeVersion string `gorm:"column:code_version;size:40" json:"code_version"`
CodeBranch string `gorm:"column:code_branch;size:40" json:"code_branch"`
CommitMsg string `gorm:"column:code_commit_msg;size:200" json:"code_commit_msg"`
Author string `gorm:"column:code_commit_author;size:40" json:"code_commit_author"`
//FinalStatus app version status