Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Uploading artifact to repository downloads

N0tSure
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!
June 19, 2018

Hi, I have next deploying plan:

  • run test Gradle
  • build artifact and upload to repository downloads

I'm read Bitbucket's manual, create app password, give permission for it to write repository. I create environment variable BB_AUTH_STRING and assign my_username:app_password as value.

But when I trying upload artifact, I receive 401 status from api.bitbucket.org

I try upload file from my local machine with same parameters:

export BB_AUTH_STRING=userName:app_password
export BITBUCKET_REPO_OWNER=team_name
export BITBUCKET_REPO_SLUG=repository_name
echo $(date) > foo.txt
curl -i -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@foo.tx

 Curl returns 201 status and file has been uploaded.

When I run same commands in pipeline, curl return follow output:

+ echo $(date) > foo.txt

+ curl -i -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@foo.txt
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   215    0     0  100   215      0    335 --:--:-- --:--:-- --:--:--   335
100   215    0     0  100   215      0    335 --:--:-- --:--:-- --:--:--   335
HTTP/2 401
server: nginx
www-authenticate: Basic realm="Bitbucket.org HTTP"
content-type: text/html; charset=utf-8
strict-transport-security: max-age=31536000; includeSubDomains; preload
date: Tue, 19 Jun 2018 19:56:51 GMT
x-served-by: app-188
x-static-version: acb0ee83c5f1
etag: "d41d8cd98f00b204e9800998ecf8427e"
x-render-time: 0.58420586586
x-version: acb0ee83c5f1
x-request-count: 241
x-frame-options: SAMEORIGIN
content-length: 0

1 answer

1 accepted

0 votes
Answer accepted
N0tSure
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!
June 20, 2018

Look like when app password creates, in dialogue New app password, in end of field with password, string end with space. I copy-past this value to BB_AUTH_STRING, and meet problem with authentication in pipeline, but on local machine I'm decide to remove this space, and forget this.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events