首页 > 解决方案 > 通过带有参数的 API 调用 Bitbucket 管道

问题描述

我有一个将从外部触发的 bitbucket 管道:

  custom:
    # This Pipeline will be triggered automatically when the setup succeeds
    test-deployment:
      - variables:
          - name: build_number
      - step:
          name: "Test"
          image: atlassian/default-image:latest
          script:
            - echo $build_number
            - export

我必须将参数“build_number”传递给这个管道,我通过以下调用尝试了这个:

curl -X POST -is -u user:pass \
-H 'Content-Type: application/json' \
https://api.bitbucket.org/2.0/repositories/user/repo/pipelines/ \
-d '
{
"target": {
  "ref_type": "branch",
  "type": "pipeline_ref_target",
  "ref_name": "feature/pipeline-tests",
  "selector": {
    "type": "custom",
    "pattern" : "test-deployment"
    }
  }
},
"variables": [
  {
    "key" : "build_number",
    "value" : "202"
    }
  ]
}'

但是没有设置“build_number”。如果我通过 Bitbucket UI 调用管道,它可以工作。这里有什么问题?

标签: bitbucket-pipelinesbitbucket-api

解决方案


推荐阅读