Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket Server REST API v1.0 how to POST / attach file to branch or Pull Request?

Martin Woods
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 21, 2019

Hi,

I've created a file containing a Terraform Plan via Octopus Deploy

We're using Bitbucket Server as our GIT repo, the Octopus job is triggered from a PR in BB which in turn builds a package in Jenkins that then uploads it to OD

There is a Terraform Plan step in OD that then creates a file containing that Plan, I've just saved it as a text file on the File System that OD runs on which happens to be Windows

I'd like to use Powershell to run Invoke-RestMethod to copy the file from the Windows server to the BB PR

But to intially test this I'd like to run a curl command on a test text file from a linux command line as the syntax is a lot simpler to Powershell

If i then get the curl to work I'd be happy to move onto Powershell, but I've had no success so far even getting the curl to work

curl -u example:pass -X POST https://api.bitbucket.org/2.0/repositories/example/example.bitbucket.io/src -F example.jpg=@example.jpg

I've tried testing the example above but it seems to be the syntax for what I believe is Cloud API v2.0 which is NOT what we're running, I want to know the equivlant for BB Server 1.0?

I've had a look through the links at the following URL and I still cannot seem to find what I'm looking for - https://developer.atlassian.com/server/bitbucket/reference/rest-api/

 

I've also looked at this page and tried the example referring to the `attachments` - https://confluence.atlassian.com/bitbucketserverkb/how-to-enclose-file-to-pull-request-comment-via-rest-api-952073003.html

 

Can someone let me know if this is possible and provide an example of the correct syntax and also a link to the documentation I should be looking at if it exists? 

 

I'd also like to know if this is possible, how do I go about letting curl know the PR or branch I want to attach a file to?

 

The only thing I have got to work is that I created a Personal API Key and I'm using it as Curl Bearer Token to auth against URI's in my BB Server

 

Many Thanks,

Martin

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events