修复用户有相同工作区问题
This commit is contained in:
parent
1578be6b4b
commit
25581bcbf9
|
|
@ -37,6 +37,12 @@ func FindUserByID(id int) []proto.User {
|
|||
return users
|
||||
}
|
||||
|
||||
func FindUserByUserID(id int) User {
|
||||
var user User
|
||||
DB.Debug().Where("id = ?", id).First(&user)
|
||||
return user
|
||||
}
|
||||
|
||||
func FindUserByName(name string) User {
|
||||
var user User
|
||||
fmt.Println("name:", name)
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ func RunCID(c *gin.Context) {
|
|||
// 获取用户ID
|
||||
id, _ := c.Get("id")
|
||||
authID := int(id.(float64))
|
||||
username, _ := c.Get("username")
|
||||
cid := dao.FindCIDByID(req.ID, authID)
|
||||
if cid.ID == 0 {
|
||||
c.JSON(200, gin.H{"error": "CID not found", "code": proto.OperationFailed, "message": "failed"})
|
||||
|
|
@ -67,7 +68,7 @@ func RunCID(c *gin.Context) {
|
|||
//脚本内容
|
||||
scriptContent := `
|
||||
echo "start"
|
||||
TARGET_DIR=` + proto.CID_BASE_DIR + `workspace/` + name + `
|
||||
TARGET_DIR=` + proto.CID_BASE_DIR + username.(string) + `/workspace/` + name + ` //不同用户的持续集成、部署目录不同
|
||||
if [ ! -d $TARGET_DIR ]; then
|
||||
git clone ` + cid.Url + `
|
||||
cd $TARGET_DIR
|
||||
|
|
@ -204,9 +205,10 @@ func CIDCallback(c *gin.Context) {
|
|||
name := strs[len(strs)-1]
|
||||
names := strings.Split(name, ".")
|
||||
name = names[0]
|
||||
user := dao.FindUserByUserID(res.Auth_id)
|
||||
scriptContent := `
|
||||
echo "start"
|
||||
TARGET_DIR=` + proto.CID_BASE_DIR + `workspace/` + name + `
|
||||
TARGET_DIR=` + proto.CID_BASE_DIR + user.Name + `workspace/` + name + `
|
||||
if [ ! -d $TARGET_DIR ]; then
|
||||
git clone ` + res.Url + `
|
||||
cd $TARGET_DIR
|
||||
|
|
|
|||
Loading…
Reference in New Issue