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

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

Michael Wallace Silva de Souza June 22, 2017

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

1 vote
Piotr Bojko
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 31, 2018

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 

0 votes
Michael Wallace Silva de Souza June 28, 2017

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"

 

 

LazyDevelopment May 21, 2018

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)"
Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events