0

HI I am trying to download a file based on the bit bucket branch selection . I am able to download the file from ci or master branch , but unable to download from feature branch. Can you please help me .

If i download from CI branch it works : https://api.bitbucket.org/2.0/repositories/***Dev/testrepo/src/ci/pom.xml - this works without any issues

https://api.bitbucket.org/2.0/repositories/***Dev/testrepo/src/feature/testFeature/pom.xml - this is not working and getting java.io.FileNotFoundException:

Could you guys please help me. Thanks in Advance.

Hanuman
  • 43
  • 5

2 Answers2

0

Try this...

https://api.bitbucket.org/2.0/repositories/{workspace}/{repo}/src/{branchHash}/{path}

For branch names which include a '/' you need to use the branch hash which you can get from,

https://api.bitbucket.org/2.0/repositories/{workspace}/{repo}/refs/branches/
Greg
  • 1
0

the above solution works only to read a file from master and ci branch ( where branch name is not having any slashes in it ) , it will not work for feature/Release branches .

I am doing it by fetching the last commit hash and with the commit hash and reading the file with last commit hash

https://api.bitbucket.org/2.0/repositories/domainname/repositoryName/refs/branches/branchName

From the Json read the commit hash - responseJsonMap["target"]["hash"]

Then construct the URL with commit hash and read the file https://api.bitbucket.org/2.0/repositories/domainName/repositoryName/src/${hashValue}/pom.xml?at=branchName

Hanuman
  • 43
  • 5