curl 如何通过Bitbucket(云)API创建分支限制

mrzz3bfm  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(149)

我正在尝试使用下面的curl命令创建分支限制,但是它抛出了一个错误请求。我如何创建一个有效的API调用?这是在Jenkins上使用sh执行的,并用双引号(“”)括起来。

curl -X POST -s 'https://api.bitbucket.org/2.0/repositories/$workspace/$repository/branch-restrictions' \
                        --header 'Authorization: Bearer $token' \
                        --header 'Accept: application/json' \
                        --header 'Content-Type: application/json' \
                        --data '{\"type\" : \"branchrestriction\",\"links\": {\"self\": {\"href\": \"https://api.bitbucket.org/2.0/repositories/$workspace/$repository/branch-restrictions\",}},\"kind\":\"push\",\"branch_match_kind\": \"branching_model\",\"branch_type\": \"feature\",\"pattern\": \"feature/*\",\"users\": [\"$user\"],\"groups\": []}'
w8rqjzmb

w8rqjzmb1#

由于与其他字段不兼容,我可以通过删除其他字段来成功添加分支限制。请参阅以下更改。
“我不知道,我不知道,我不知道。”
--header '授权:不记名$token'
--header '接受:应用程序/json'
--header '内容类型:应用程序/json'
--数据'{“类型”:“分支限制”,“种类”:“推送”,“分支匹配种类”:“团”、“图案”:“功能/*",“用户”:[],“组”:[]}

相关问题