使用Stash(bitbucket服务器)REST API将文件提交到git存储库

时间:2016-10-14 08:01:16

标签: git bitbucket-server bitbucket-api

我正在使用Atlassian Stash(Bitbucket服务器)来管理我的git存储库。最近我要求使用Stash REST API将文件(新创建的.xml文件)提交到我的Git存储库。我已经阅读了文档,但似乎REST API不支持该功能。

我是否正确,或者这可能以某种方式?

2 个答案:

答案 0 :(得分:4)

这不能通过Stash / Bitbucket Server REST API完成。我不得不转移到JGit,它是GIT和Application之间通信的Java包装器。

问题 Is it possible to commit a file to a remote base repository using JGit 有更多信息。

答案 1 :(得分:2)

可能你正在寻找

PUT /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:.*}

来自API的文档

  

PUT   /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:*}

     

更新给定存储库和分支上的路径内容。这个   资源接受PUT多部分表单数据,包含文件   表单字段命名内容。要更新的curl请求示例   ' README.md'将是:

     
    

curl -X PUT -u用户名:密码-F content =@README.md -F     ' message =使用文件编辑REST API更新' -F branch = master -F     sourceCommitId = 5636641a50b http://example.com/rest/api/latest/projects/PROJECT_1/repos/repo_1/browse/README.md

  
     
      
  • 分支:应修改或创建路径的分支
  •   
  • content:路径消息中文件的完整内容:消息   与此更改相关联,用作提交消息。或者为null   如果应该使用默认消息。
  •   
  • sourceCommitId:提交ID   编辑之前的文件,用于识别内容是否有   改变。如果这是一个新文件,则返回null。
  •   
     

文件可以更新或   在新的分支上创建。在这种情况下,sourceBranch参数   应提供以确定新分支的起点   branch参数标识要创建新分支的分支   承诺。