- curl -v -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=@"app/build/outputs/apk/debug/*.apk"
I am using the above curl statement as it is, but it's failing and giving me the following error
Warning: setting file app/build/outputs/apk/debug/*.apk failed!
Note: Unnecessary use of -X or --request, POST is already inferred.
Hello @deepak_rathi,
AFAIK, to upload an array with cURL you need to use another syntax, something like
curl -F 'files[]=@/path/to/first/file' -F 'files[]=@/path/to/second/file' ...
Hope this helps.
Cheers,
Daniil
I don't want to upload an array. I just want to upload a single apk file to the download section.
Further, I did not create an app password for auth, I was wondering from where it was being picked but later on understood that I have to create an app password and make an account variable, did that but still getting the error now.
Warning: setting file app/build/outputs/apk/debugQA/*.apk failed!
Enter host password for user '':
% 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 150 0 0 0 150 0 2083 --:--:-- --:--:-- --:--:-- 2083
curl: (26) read function returned funny value
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
cURL doesn't understand the * symbol, the path has to be specific to a single file.
Enter host password for user '':
This line means your credentials are not passed in properly. In bash variables are not substituted when inside of double quotes – move them out (for credentials you don't need quotes at all).
Then add verbose logging (curl -v) and check what's inside of Authorization header – it should be a base64 encoded string of username:password string.
I have to create an app password and make an account variable
What do you mean by account variable here?
Cheers,
Daniil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why the error message language is so difficult to understand, the should have been something like file not located/found at the given path or something.
I'll do changes.
By account varible i meant - I have to set BB_AUTH_STRING in account variable right? just as suggested by you -> "it should be a base64 encoded string of username:password string"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
By account varible i meant - I have to set BB_AUTH_STRING in account variable right? just as suggested by you -> "it should be a base64 encoded string of username:password string"
No, I was saying that in the log it would be a base64 string. In terms of configuration, it is easier to set username and password separately in two different variables, then use them in your cURL command like this:
curl -u ${BB_USERNAME}:${BB_PASSWORD} ...
Cheers,
Daniil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniil
This is working as supposed to. Thank you!
One more question I have - can we rename the file here which is being uploaded to Downloads?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No worries :)
Yes, specify filename property like this:
curl ... --form 'files=@/path/to/file/foo.apk;filename=bar.apk'
This will upload it as bar.apk.
Cheers,
Daniil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, thanks Daniil!
There must be so much more to learn, could you please give me the link Daniil so I can read more and understand more.
Thank you so much for all your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No worries, glad to help :)
A link to what? So far I was just using Google to clarify curl options...
Cheers,
Daniil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A link where i could read all these curl options and their customization, there must a documentation from bitbucket i hope.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, curl is a very popular tool and it already has very detailed manuals (just an example, it is also available via man page) as well as heaps of articles, blog posts and various examples on the Internet.
As for Bitbucket, we have API documentation covering all endpoints of the public API. For instance here's the endpoint for uploading files to repository Downloads which we're talking about. Those pages sometimes refer to curl commands as an example, but way not for all endpoints and their features. We're working on improving our documentation though, so hopefully it will become better.
Cheers,
Daniil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@deepak_rathi Can you please share your entire Yaml File here? Am still facing the same problem you faced.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The provided curl statement for uploading an Android APK file to Bitbucket downloads has a syntax issue. The error indicates that setting the file using the wildcard "*.apk" is not supported. Instead, specify the exact file path without the wildcard. Modify the statement as follows:
curl -v -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=@"app/build/outputs/apk/debug/your_app_name.apk"
Replace "your_app_name" with the actual name of your APK file. This should resolve the error and allow you to upload the artifact to Bitbucket downloads.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.