community.general.bitbucket_pipeline_variable 模块 – 管理 Bitbucket 流水线变量

注意

此模块是 community.general 集合 (版本 10.1.0) 的一部分。

如果您正在使用 ansible 包,您可能已经安装了这个集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.general

要在 playbook 中使用它,请指定:community.general.bitbucket_pipeline_variable

概要

  • 管理 Bitbucket 流水线变量。

参数

参数

注释

client_id

字符串

OAuth 消费者密钥。

如果未设置,将使用环境变量 BITBUCKET_CLIENT_ID

client_secret

字符串

OAuth 消费者密钥。

如果未设置,将使用环境变量 BITBUCKET_CLIENT_SECRET

name

字符串 / 必填

流水线变量名称。

password

字符串

在 community.general 4.0.0 中添加

App 密码。

如果未设置,将使用环境变量 BITBUCKET_PASSWORD

repository

字符串 / 必填

仓库名称。

secured

布尔值

是否加密变量值。

选择

  • false ← (默认)

  • true

state

字符串 / 必填

指示变量的期望状态。

选择

  • "absent"

  • "present"

user

别名:username

字符串

在 community.general 4.0.0 中添加

用户名。

如果未设置,将使用环境变量 BITBUCKET_USERNAME

usernameuser 的别名,自 community.general 6.0.0 起。它以前是 workspace 的别名。

value

字符串

流水线变量值。

workspace

字符串 / 必填

仓库所有者。

注意: username 曾经是此选项的别名。自 community.general 6.0.0 起,它是 user 的别名。

属性

属性

支持

描述

check_mode

支持: 完全

可以在 check_mode 下运行并返回已更改状态的预测,而无需修改目标。

diff_mode

支持:

当处于 diff 模式时,将返回有关已更改(或可能需要在 check_mode 中更改)的详细信息。

说明

注意

  • 支持检查模式。

  • 对于安全值,返回参数 changed 始终为 true

  • Bitbucket OAuth 消费者密钥和密钥可以从 Bitbucket 个人资料 -> 设置 -> 访问管理 -> OAuth 中获得。

  • Bitbucket App 密码可以从 Bitbucket 个人资料 -> 个人设置 -> App 密码中创建。

  • 如果同时传递 OAuth 和基本身份验证凭据,则 OAuth 凭据优先。

示例

- name: Create or update pipeline variables from the list
  community.general.bitbucket_pipeline_variable:
    repository: 'bitbucket-repo'
    workspace: bitbucket_workspace
    name: '{{ item.name }}'
    value: '{{ item.value }}'
    secured: '{{ item.secured }}'
    state: present
  with_items:
    - { name: AWS_ACCESS_KEY, value: ABCD1234, secured: false }
    - { name: AWS_SECRET, value: qwe789poi123vbn0, secured: true }

- name: Remove pipeline variable
  community.general.bitbucket_pipeline_variable:
    repository: bitbucket-repo
    workspace: bitbucket_workspace
    name: AWS_ACCESS_KEY
    state: absent

作者

  • Evgeniy Krysanov (@catcombo)