【问题标题】:Bitbucket API Update Pipeline VariableBitbucket API 更新管道变量
【发布时间】:2021-10-14 19:38:30
【问题描述】:

我无法成功更新存储库变量,也不知道为什么它不起作用。

我已经能够通过 API 获取所有必要的 ID,并且正在发出以下 curl 请求:

curl -X PUT "https://api.bitbucket.org/2.0/repositories/{workspace}/{repository}/pipelines_config/variables/{variable_uuid}" -H 'Content-Type: application/json' -d '{"value":"{value}","key":"{name}"}'

从这里我得到:

{"type": "error", "error": {"message": "Resource not found"}}

有没有人知道我已经尝试改变我能想到的所有东西但没有运气

【问题讨论】:

标签: bitbucket bitbucket-pipelines bitbucket-api


【解决方案1】:

找到了

#!/bin/bash

set -x

export USER_NAME=user_name
export PASSWORD=password

curl --user "$USER_NAME":"$PASSWORD" 'https://api.bitbucket.org/2.0/repositories/{user_name}/{application}/pipelines_config/variables/' -H 'Content-Type: application/json'

curl -vX PUT -u "$USER_NAME":"$PASSWORD" --url 'https://api.bitbucket.org/2.0/repositories/{user_name}/{application}/pipelines_config/variables/%7B21212121-2d1e-201a-21c2-212121a21212%7D' -H 'Content-Type:application/json' -d "{\"value\":\"new_value\", \"key\":\"variable\"}"

https://community.atlassian.com/t5/Bitbucket-questions/How-to-get-variable-uuid/qaq-p/1496735

【讨论】:

    【解决方案2】:
    - curl -v -X PUT "https://api.bitbucket.org/2.0/repositories/$ORG_OR_WORKSPACE/$REPO/pipelines_config/variables/\{$HASH_VARIABLE\}" -H "Content-Type:application/json" -d "{\"key\":\"$VARIABLE_NAME\", \"value\":\"$VARIABLE_VALUE\" }" --user $PIPELINE_APP_PASS
    

    实际的哈希需要用括号{}括起来,用\转义

    尝试从终端运行命令以确保您可以更新变量。您可能想创建一个具有访问权限的用户应用密码,应该是username:password

    【讨论】:

      猜你喜欢
      • 2019-08-23
      • 2019-12-30
      • 2023-02-03
      • 2021-12-10
      • 2021-06-13
      • 1970-01-01
      • 2019-09-01
      • 1970-01-01
      • 2021-11-23
      相关资源
      最近更新 更多