mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-02 11:47:36 +08:00
[REV] optimization implementation
This commit is contained in:
parent
c30483a085
commit
9227f8faed
@ -121,6 +121,7 @@ func GitClone(csi CodeSourceInfo, sourceDir string, logger event.Logger, timeout
|
|||||||
GetPrivateFileParam := csi.TenantID
|
GetPrivateFileParam := csi.TenantID
|
||||||
flag := true
|
flag := true
|
||||||
Loop:
|
Loop:
|
||||||
|
fmt.Println(GetPrivateFileParam,flag)
|
||||||
if logger != nil {
|
if logger != nil {
|
||||||
//进度信息
|
//进度信息
|
||||||
logger.Info(fmt.Sprintf("开始从Git源(%s)获取代码", csi.RepositoryURL), map[string]string{"step": "clone_code"})
|
logger.Info(fmt.Sprintf("开始从Git源(%s)获取代码", csi.RepositoryURL), map[string]string{"step": "clone_code"})
|
||||||
@ -205,6 +206,7 @@ Loop:
|
|||||||
flag = false
|
flag = false
|
||||||
goto Loop
|
goto Loop
|
||||||
}
|
}
|
||||||
|
fmt.Println("第二次1")
|
||||||
if logger != nil {
|
if logger != nil {
|
||||||
logger.Error(fmt.Sprintf("拉取代码发生错误,代码源鉴权失败。"), map[string]string{"step": "callback", "status": "failure"})
|
logger.Error(fmt.Sprintf("拉取代码发生错误,代码源鉴权失败。"), map[string]string{"step": "callback", "status": "failure"})
|
||||||
}
|
}
|
||||||
@ -229,6 +231,14 @@ Loop:
|
|||||||
return rs, fmt.Errorf("branch %s is not exist", csi.Branch)
|
return rs, fmt.Errorf("branch %s is not exist", csi.Branch)
|
||||||
}
|
}
|
||||||
if strings.Contains(err.Error(), "ssh: unable to authenticate") {
|
if strings.Contains(err.Error(), "ssh: unable to authenticate") {
|
||||||
|
logrus.Info("没有找到ssh")
|
||||||
|
|
||||||
|
if flag {
|
||||||
|
GetPrivateFileParam = "builder_rsa"
|
||||||
|
flag = false
|
||||||
|
goto Loop
|
||||||
|
}
|
||||||
|
fmt.Println("第二次2")
|
||||||
if logger != nil {
|
if logger != nil {
|
||||||
logger.Error(fmt.Sprintf("远程代码库需要配置SSH Key。"), map[string]string{"step": "callback", "status": "failure"})
|
logger.Error(fmt.Sprintf("远程代码库需要配置SSH Key。"), map[string]string{"step": "callback", "status": "failure"})
|
||||||
}
|
}
|
||||||
@ -263,6 +273,7 @@ func GitPull(csi CodeSourceInfo, sourceDir string, logger event.Logger, timeout
|
|||||||
GetPrivateFileParam := csi.TenantID
|
GetPrivateFileParam := csi.TenantID
|
||||||
flag := true
|
flag := true
|
||||||
Loop:
|
Loop:
|
||||||
|
fmt.Println(GetPrivateFileParam,flag)
|
||||||
if logger != nil {
|
if logger != nil {
|
||||||
//进度信息
|
//进度信息
|
||||||
logger.Info(fmt.Sprintf("开始从Git源(%s)更新代码", csi.RepositoryURL), map[string]string{"step": "clone_code"})
|
logger.Info(fmt.Sprintf("开始从Git源(%s)更新代码", csi.RepositoryURL), map[string]string{"step": "clone_code"})
|
||||||
@ -341,6 +352,7 @@ Loop:
|
|||||||
flag = false
|
flag = false
|
||||||
goto Loop
|
goto Loop
|
||||||
}
|
}
|
||||||
|
fmt.Println("第二次1")
|
||||||
|
|
||||||
if logger != nil {
|
if logger != nil {
|
||||||
logger.Error(fmt.Sprintf("更新代码发生错误,代码源鉴权失败。"), map[string]string{"step": "callback", "status": "failure"})
|
logger.Error(fmt.Sprintf("更新代码发生错误,代码源鉴权失败。"), map[string]string{"step": "callback", "status": "failure"})
|
||||||
@ -366,6 +378,14 @@ Loop:
|
|||||||
return rs, fmt.Errorf("branch %s is not exist", csi.Branch)
|
return rs, fmt.Errorf("branch %s is not exist", csi.Branch)
|
||||||
}
|
}
|
||||||
if strings.Contains(err.Error(), "ssh: unable to authenticate") {
|
if strings.Contains(err.Error(), "ssh: unable to authenticate") {
|
||||||
|
logrus.Info("没有找到ssh")
|
||||||
|
|
||||||
|
if flag {
|
||||||
|
GetPrivateFileParam = "builder_rsa"
|
||||||
|
flag = false
|
||||||
|
goto Loop
|
||||||
|
}
|
||||||
|
fmt.Println("第二次2")
|
||||||
if logger != nil {
|
if logger != nil {
|
||||||
logger.Error(fmt.Sprintf("远程代码库需要配置SSH Key。"), map[string]string{"step": "callback", "status": "failure"})
|
logger.Error(fmt.Sprintf("远程代码库需要配置SSH Key。"), map[string]string{"step": "callback", "status": "failure"})
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ func init() {
|
|||||||
func TestGitClone(t *testing.T) {
|
func TestGitClone(t *testing.T) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
csi := CodeSourceInfo{
|
csi := CodeSourceInfo{
|
||||||
RepositoryURL: "https://github.com/goodrain/rainbond-docs.git",
|
RepositoryURL: "git@gitee.com:zhoujunhaogoodrain/webhook_test.git",
|
||||||
Branch: "master",
|
Branch: "master",
|
||||||
}
|
}
|
||||||
//logger := event.GetManager().GetLogger("system")
|
//logger := event.GetManager().GetLogger("system")
|
||||||
@ -49,7 +49,7 @@ func TestGitClone(t *testing.T) {
|
|||||||
|
|
||||||
func TestGitPull(t *testing.T) {
|
func TestGitPull(t *testing.T) {
|
||||||
csi := CodeSourceInfo{
|
csi := CodeSourceInfo{
|
||||||
RepositoryURL: "git@code.goodrain.com:goodrain/test.git",
|
RepositoryURL: "git@gitee.com:zhoujunhaogoodrain/webhook_test.git",
|
||||||
Branch: "master2",
|
Branch: "master2",
|
||||||
}
|
}
|
||||||
//logger := event.GetManager().GetLogger("system")
|
//logger := event.GetManager().GetLogger("system")
|
||||||
@ -66,8 +66,7 @@ func TestGitPull(t *testing.T) {
|
|||||||
|
|
||||||
func TestGitPullOrClone(t *testing.T) {
|
func TestGitPullOrClone(t *testing.T) {
|
||||||
csi := CodeSourceInfo{
|
csi := CodeSourceInfo{
|
||||||
RepositoryURL: "git@code.goodrain.com:goodrain/goodrain_web.git",
|
RepositoryURL: "git@gitee.com:zhoujunhaogoodrain/webhook_test.git",
|
||||||
Branch: "publiccloud",
|
|
||||||
}
|
}
|
||||||
//logger := event.GetManager().GetLogger("system")
|
//logger := event.GetManager().GetLogger("system")
|
||||||
res, err := GitCloneOrPull(csi, "/tmp/goodrainweb2", nil, 1)
|
res, err := GitCloneOrPull(csi, "/tmp/goodrainweb2", nil, 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user