脚本部分添加内容

This commit is contained in:
junleea 2024-07-07 12:04:23 +08:00
parent 25581bcbf9
commit 4178bf0622
1 changed files with 6 additions and 2 deletions

View File

@ -65,10 +65,10 @@ func RunCID(c *gin.Context) {
names := strings.Split(name, ".") names := strings.Split(name, ".")
name = names[0] name = names[0]
//脚本内容 //脚本内容,不同用户的持续集成、部署目录不同
scriptContent := ` scriptContent := `
echo "start" echo "start"
TARGET_DIR=` + proto.CID_BASE_DIR + username.(string) + `/workspace/` + name + ` //不同用户的持续集成、部署目录不同 TARGET_DIR=` + proto.CID_BASE_DIR + username.(string) + `/workspace/` + name + `
if [ ! -d $TARGET_DIR ]; then if [ ! -d $TARGET_DIR ]; then
git clone ` + cid.Url + ` git clone ` + cid.Url + `
cd $TARGET_DIR cd $TARGET_DIR
@ -77,6 +77,8 @@ else
git pull git pull
fi fi
` + cid.Script + ` ` + cid.Script + `
pwd
ls -lh
echo "end"` echo "end"`
//执行脚本 //执行脚本
cmd := exec.Command("/bin/bash", "-c", scriptContent) cmd := exec.Command("/bin/bash", "-c", scriptContent)
@ -217,6 +219,8 @@ else
git pull git pull
fi fi
` + res.Script + ` ` + res.Script + `
pwd
ls -lh
echo "end"` echo "end"`
//执行脚本 //执行脚本
cmd := exec.Command("/bin/bash", "-c", scriptContent) cmd := exec.Command("/bin/bash", "-c", scriptContent)