Pipelines のビルド番号に新しい値を設定する

お困りですか?

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

コミュニティに質問

Pipelines のビルド番号の更新

You can use the Bitbucket REST API to set the Pipelines build number $BITBUCKET_BUILD_NUMBER to a higher value. You might want to do this if you are moving from another build tool where you already have built versions of your software with a higher build number.

手順

  1. Log into Bitbucket and click on gear(or cog) icon next to your avatar, select "personal bitbucket settings".

  2. From the Personal settings page, under Access management, select App passwords.

  3. Create a new app password with permission to "edit variables" in Pipelines. Copy the new password to your clipboard.  You will be using your username and the app password, not the app password label.

  4. curl を使用して Pipelines build_number config API に PUT します。

    curl -v -H 'Content-Type: application/json' -XPUT \
      -d '{ "next": 1000 }' \
      --user 'USERNAME:PASSWORD' \
      'https://api.bitbucket.org/2.0/repositories/WORKSPACE/REPONAME/pipelines_config/build_number'


この例で、次の情報を置き換えます。

  • 1000  with the next desired build number

  • USERNAME with your Bitbucket username 

  • PASSWORD with the app password you generated and copied above

  • REPONAME with the slug of your repository.

正常に完了すると、Bitbucket が次のような応答を返します。

{"type": "pipeline_build_number", "next": 1000}

次に実行する Pipelines ビルドではこれがビルド番号として使用されます。

エラー応答

エラー応答には次のようなものがあります。

  • HTTP/1.1 401 Unauthorized – this comes back as an HTTP header if Bitbucket can't identify your username. Make sure you change the command above to have the correct username in both the URL and the --user parameter.

  • Your credentials lack one or more required privilege scopes – you need to ensure your app password has the permission to Edit Pipelines variables.

  • An invalid field was found in the JSON payload – you need to ensure your JSON payload matches the format above, a single object with a next field with an integer value (type is optional).

  • The request body contains invalid properties - 指定したビルド番号が Pipelines の既存のビルドよりも小さい値です。

  • Authentication Error - "remote: Invalid username or password" - You may be using the app password label, not your username. Your Bitbucket username is listed under Bitbucket profile settings on your Bitbucket Personal settings page.

制限事項

There is no way to change the build number through the Bitbucket web UI. This change is only possible through the Bitbucket REST API.

You can't set the build number to a number that is lower than any existing build result in the repository. It is not currently possible to delete Pipelines builds, so we need to ensure the future build number will not clash with any existing build.

最終更新日 2023 年 5 月 10 日

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

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