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"

 

 

0 votes

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 Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

675 views 0 4
Read article

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot