From fe68e9383c53011254595c9db8043dbcc21ee33f Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Fri, 15 Sep 2023 13:00:24 +0800 Subject: [PATCH] gitea hook --- docker/w9gitea/init.sh | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/docker/w9gitea/init.sh b/docker/w9gitea/init.sh index 3969b199..24c7bd05 100644 --- a/docker/w9gitea/init.sh +++ b/docker/w9gitea/init.sh @@ -20,7 +20,7 @@ echo "$json" > "$filename" api_url="http://localhost:3000/api/v1" hook_url="http://gitea:8080" -# 创建新hook的数据 +# Param data hook_data='{ "type": "gitea", "config": { @@ -31,19 +31,5 @@ hook_data='{ "active": true }' -# 从JSON文件中读取用户名和密码 -username=$(jq -r '.username' "$filename") -password=$(jq -r '.password' "$filename") - -# 发送POST请求创建新hook -response=$(curl -s -u "$username:$password" -X POST -H "Content-Type: application/json" -d "$hook_data" "$api_url/user/hooks") - -# 检查响应状态码 -status_code=$(echo "$response" | jq -r '.status') -if [[ $status_code == "ok" ]]; then - echo "New hook created successfully." -else - error_message=$(echo "$response" | jq -r '.message') - echo "Failed to create new hook: $error_message" -fi - +# Create a hook +curl -s -u "$username:$password" -X POST -H "Content-Type: application/json" -d "$hook_data" "$api_url/user/hooks" \ No newline at end of file