Lesstep
Bitbucket Cloud・Pipelines・2026年10月31日に確認

Bitbucket Pipelines:custom のパイプラインを変数つきで実行する

bitbucket-pipelines.yml の custom: に書いたパイプラインは、push では動きません。手で始めるか、スケジュールか、スクリプトから REST API で始めます。毎回、変数を聞くこともできます。スクリプトから始めたときに一番多い答えは、ファイルがあるのに返る HTTP 400 「bitbucket-pipelines.yml not found.」です。下の公開の報告は、どれもリクエストの selector が原因でした。

変数を書く

Atlassian の pipeline start conditions より:custom のパイプラインは、先頭に variables の一覧を置けます。変数ごとに name(必須)、あれば default・allowed-values・description を書きます。

pipelines:
  custom:
    deploy-staging:            # パイプラインの名前
      - variables:
          - name: VERSION
            description: "デプロイするタグかコミット"
          - name: REGION
            default: "eu-west-1"
            allowed-values:
              - "eu-west-1"
              - "us-east-1"
      - step:
          script:
            - ./deploy.sh "$VERSION" "$REGION"

Bitbucket の画面で実行する

Atlassian の scheduled and manually triggered pipelines より:リポジトリの Pipelines のページで Run pipeline を選びます。ブランチかタグ、パイプラインを選び、変数を入れて Run。Branches と Commits のページでも、ブランチやコミットの … のメニューに Run pipeline があります。実行には、リポジトリへの書き込みの権限が要ります。

REST API で実行する

Bitbucket の Pipelines の API の Run a pipeline:

curl -X POST -u '<メールアドレス>:<API トークン>' \
  -H 'Content-Type: application/json' \
  https://api.bitbucket.org/2.0/repositories/WORKSPACE/REPO/pipelines/ \
  -d '{
    "target": {
      "type": "pipeline_ref_target",
      "ref_type": "branch",
      "ref_name": "main",
      "selector": { "type": "custom", "pattern": "deploy-staging" }
    },
    "variables": [
      { "key": "VERSION", "value": "v2.4.1" },
      { "key": "REGION", "value": "us-east-1" }
    ]
  }'

「bitbucket-pipelines.yml not found.」

HTTP 400
{"error": {"message": "Bad request", "detail": "bitbucket-pipelines.yml not found.",
  "data": {"key": "result-service.pipeline.yml-not-found", "arguments": {}}}}

Bitbucket の API の説明では、ここでの 400 の理由は3つです。アカウントかリポジトリで Pipelines が有効でない、そのリビジョンにファイルが無い、本文の項目が正しくない。Atlassian のコミュニティの公開の4件では、ファイルはあり、画面の Run pipeline も動き、リクエストのほうが原因でした:

確かめる順番:target に type が custom の selector がある。その pattern が custom: の下のキーと1文字も違わない。そのキーが、ref_name のブランチの bitbucket-pipelines.yml にある。

IntelliJ IDEA から custom のパイプラインを実行するなら

Pipeline Inbox for Bitbucket Pipelines は、Lesstep が作っている JetBrains IDE(2024.1 以降)のプラグインです。Bitbucket Cloud のすべてのリポジトリのパイプラインを IDE のツールウィンドウに並べます。パイプラインを実行…(英語の画面では Run Pipeline…)は、選んだブランチの bitbucket-pipelines.yml を読み、そのブランチ用のパイプラインと、そこにある custom のパイプラインを並べます。送る名前は、いつもファイルにある名前です。書いてある変数ごとに入力欄(allowed-values があれば選択肢)を出し、default を入れておき、値を覚えることもできます(secured の値は覚えません)。それでも Bitbucket が断ったときは、Bitbucket の言葉のまま出します。一覧・ステップ・ログは無料、実行・もう一度実行・停止は Pro(月 US$1.50・30日間の無料試用つき)です。画面は日本語です。

JetBrains Marketplace で入手

Atlassian、Bitbucket、Bitbucket Pipelines は Atlassian の商標、IntelliJ IDEA は JetBrains s.r.o. の商標です。このページは Atlassian・JetBrains のいずれとも提携しておらず、承認も受けていません。

ほかに:push してもパイプラインが動かない · ビルド時間を使い切った · 「No online runner available」 · 「Permission denied to update branch」 · 「You have reached your pull rate limit」(Docker Hub) · 「There is an error in your bitbucket-pipelines.yml」 · 「This pipeline was paused」(デプロイ) · IntelliJ IDEA の Bitbucket Pipelines 用プラグインの比較 · English