Deploy build artifacts to Bitbucket Downloads: 0curl: (26) couldn't open file "target/output.jar"

Hi.

I just have followed this tutorial: https://confluence.atlassian.com/bitbucket/deploy-build-artifacts-to-bitbucket-downloads-872124574.html.

but i'm  getting this error:

+ curl -X POST --user "${BITBUCKET_REPO_OWNER}:${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"target/output.jar"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed

0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (26) couldn't open file "target/output.jar"

Here is my .yml:

image: maven:3.3.3

pipelines:
  default:
    - step:
        script:
          - mvn -B clean install
          - curl -X POST --user "${BITBUCKET_REPO_OWNER}:${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"target/output.jar"

I have created an app password in my account level, with all permissions set. My Enriromental variable is configured with the generated key (like this: zBre6W************)

2 answers

I figured out the solution. I'll post here if anyone has the same question:

Anything under "script:" it's just unix commands, this means that you can use unix commands to navigate and list the files generated by your build.

My pom.xml generated the jar file with the name "my-project-1.0-SNAPSHOT", but my .yml was looking for a file named "output.jar".

I simply searched in the generated folders to see where my file was, using this command:

ls -R # Will list all files in the directory and subfolders

 

After finding the right place, i just point the "files" property to the right file in my .yml:

image: maven:3.3.3

pipelines:
  default:
    - step:
        script:
          - mvn -B clean install
- ls -R # Use this to find your generated jar. Remove it after. - curl -i -X POST --user "${BITBUCKET_REPO_OWNER}:${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads/" --form files=@"target/my-project-1.0-SNAPSHOT.jar"

 

 

If you don't want to hardcode version of your jar in the curl command, I'd suggest to write something like: 

--form files=@"target/$(cd ./target/ && ls -1 my-project*.jar)"

We've just released an experimental wagon for maven which deploys directly do bitbucket downloads - https://bitbucket.org/codedoers/maven-bitbucket-download-wagon

it does the same as curl but treats the bitbucket downloads as a maven repository 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

27,847 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you