Unable to download build artifact via web request

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Fisheye および Crucible は除く

要約

When using wget to download a build artifact via a web request with HTTP Basic Authentication and Anonymous access disabled in Bamboo, an error occurs and the downloaded file is corrupted. However, when manually entering the username and password in the Web interface, the artifact is downloaded correctly.

環境

  • Any Bamboo version
  • wget

診断

While fetching a build artifact from Bamboo via a web request using wget:

$ wget --user user --password <PASSWORD> -N <bamboo-artifact-url>

The following error is present in the atlassian-bamboo.log file:

2023-03-07 17:16:06,658 ERROR [http-nio-8085-exec-1] [AbstractDownloadStrategy] Access denied for downloads URL /<bamboo-artifact-url>

The location of the atlassian-bamboo.log file can be viewed in Bamboo's System information under the Bamboo paths section

Command logs
[root@xxx:~]# wget -N <bamboo-artifact-url>
{-}{{-}}<date-time>{{-}}{-} <bamboo-artifact-url>
Resolving <bamboo-url> (bamboo-url)... <bamboo-ip>
Connecting to <bamboo-url> (<bamboo-url>)|<bamboo-ip>|:443... connected.
HTTP request sent, awaiting response... 302
Location: <bamboo-artifact-url> [following]
{-}{{-}}<date-time>{{-}}{-} <bamboo-artifact-url>
Reusing existing connection to <bamboo-url>:443.
HTTP request sent, awaiting response... 200
Length: unspecified [text/html]
Saving to: '<artifact-name>'

原因

This happens because Bamboo does not send HTTP request authentication challenges back to the client when an Artifact URL is requested.

ソリューション

Option 1: Use the --auth-no-challenge argument with wget. Since wget 1.10.2, Basic HTTP authentication is only sent when the target HTTP server responds with an authentication challenge. By using the '--auth-no-challenge' parameter, wget will send Basic HTTP authentication information (plaintext username and password) for all requests.

$ wget --auth-no-challenge --http-user <user> --http-password <password> <bamboo-artifact-url>

Option 2: Use curl and follow redirects. curl sends Basic HTTP authentication challenges to all requests by default when a username is provided. Make sure to follow redirects by setting the --location or -L arguments:

$ curl --location --user <user>:<password> <bamboo-artifact-url> -o artifact.txt
最終更新日 2023 年 5 月 25 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.