community.general.gitlab_branch 模块 – 创建或删除分支
注意
此模块是 community.general 集合 (版本 10.1.0) 的一部分。
如果您正在使用 ansible
包,则可能已安装此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。您需要其他要求才能使用此模块,有关详细信息,请参阅 要求。
要在 playbook 中使用它,请指定:community.general.gitlab_branch
。
community.general 4.2.0 中的新增功能
概要
此模块允许创建或删除分支。
要求
执行此模块的主机需要以下要求。
python-gitlab >= 2.3.0
requests (Python 库 https://pypi.ac.cn/project/requests/)
参数
参数 |
注释 |
---|---|
用于登录的 GitLab CI 作业令牌。 |
|
用于登录的 GitLab OAuth 令牌。 |
|
用于对 API 进行身份验证的密码。 |
|
具有 API 权限的 GitLab 访问令牌。 |
|
API 的可解析端点。 |
|
用于对 API 进行身份验证的用户名。 |
|
需要创建的分支名称。 |
|
用于验证 GitLab 服务器证书的 CA 证书捆绑包。 |
|
项目的路径或名称。 |
|
从中创建的参考分支。 如果 |
|
创建或删除分支。 选项
|
|
是否在提供 HTTPS 端点时验证 SSL 证书。 选项
|
属性
属性 |
支持 |
描述 |
---|---|---|
支持:不支持 |
可以在 |
|
支持:不支持 |
处于 diff 模式时,将返回有关已更改内容(或可能需要在 |
示例
- name: Create branch branch2 from main
community.general.gitlab_branch:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
branch: branch2
ref_branch: main
state: present
- name: Delete branch branch2
community.general.gitlab_branch:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
branch: branch2
state: absent