【问题标题】:How can I download a single raw file from a private Bitbucket repo using the command line?如何使用命令行从私有 Bitbucket 存储库下载单个原始文件?
【发布时间】:2022-11-11 03:38:51
【问题描述】:

我想从私人仓库下载文件而不克隆整个内容。

我能找到的所有结果都暗示了同一件事:在 Bitbucket 中创建一个应用密码,然后将该密码与您的用户名一起使用。我尝试过这个:

curl -u my_username:app_password https://bitbucket.org/my_username/the_repo/raw/commit_sha/the_file

我知道 URL 至少是合理的,因为如果我登录到 Bitbucket,我可以在浏览器中查看它。

但是运行 curl 命令失败并出现错误:

Bitbucket Cloud recently stopped supporting account passwords for API authentication.
See our community post for more details: https://atlassian.community/t5/x/x/ba-p/1948231
App passwords are recommended for most use cases and can be created in your Personal settings:
https://bitbucket.org/account/settings/app-passwords/
For more details on API authentication methods see our documentation:
https://developer.atlassian.com/cloud/bitbucket/rest/intro/#authentication

提到的第二个链接有一个关于App Passwords 的部分,并没有说明如何实际使用它们。

使用带有git clone 的应用程序密码可以正常工作,但我不知道如何让它与 curl 一起使用。

【问题讨论】:

  • 您是否阅读了错误最后一行中链接的API docs
  • 是的,它有一个关于应用程序密码的部分,它几乎解释了它们是什么,说明了如何创建密码,然后说将其插入应用程序。我看不到实际使用情况。

标签: curl command-line bitbucket


【解决方案1】:

这对我有用:

curl -u <user>:<app_password> -L -O https://api.bitbucket.org/2.0/repositories/<org>/<repo>/src/<branch>/<file>

【讨论】:

    猜你喜欢
    • 2013-08-10
    • 1970-01-01
    • 1970-01-01
    • 2013-12-22
    • 1970-01-01
    • 2012-06-10
    • 2020-12-09
    • 2016-05-30
    • 1970-01-01
    相关资源
    最近更新 更多