根据GITLAB API文档,我希望在单个分支上创建多个提交,然后在bash脚本中创建一个合并请求。
curl -i --request POST --header "PRIVATE-TOKEN: privatekey" --header "Content-Type: application/json" --data "$PAYLOAD" "https://hostgit/api/v4/projects/1234/repository/commits"和关于有效负载
PAYLOAD=$(cat << JSON
{
"branch": "mybranch",
"commit_message": "some commit message",
"actions": [
{
"action": "update",
"file_path": "roles/test.j2"
},
{
"action": "update",
"file_path": "roles/prod.j2"
}
]
}
JSON
)脚本更新文件,因此在此提交后,我使用了create MR,但它是一个空的MR.why,它是空的??提交更改为0。此外,我在操作中使用了一个文件路径的内容,但它不起作用,提交仍然为空。
发布于 2021-03-13 00:11:10
对于update操作,您必须指定文件的内容,它应该是整个文件内容,而不仅仅是更新的部分。Gitlab随后将生成diff并正确提交更改。您需要更新您的有效负载,使其看起来类似于:
PAYLOAD=$(cat << JSON
{
"branch": "mybranch",
"commit_message": "some commit message",
"actions": [
{
"action": "update",
"file_path": "roles/test.j2",
"content": "this is the entire content in the test.j2 file after updating it"
},
{
"action": "update",
"file_path": "roles/prod.j2",
"content": "This is the entire content in the prod.j2 file after updating it"
}
]
}
JSON
)您可以在the docs中查看所有可选和必需的参数。]
https://stackoverflow.com/questions/66598470
复制相似问题