mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 18:50:21 -07:00
add module gitlab_branch (#3795)
* add module gitlab_branch * Update plugins/modules/source_control/gitlab/gitlab_branch.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/source_control/gitlab/gitlab_branch.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/source_control/gitlab/gitlab_branch.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update gitlab_branch.py * Update gitlab_branch.py * Update gitlab_branch.py * add integration tests * Update BOTMETA.yml * Update gitlab_branch.py * Update tests/integration/targets/gitlab_branch/aliases Co-authored-by: Felix Fontein <felix@fontein.de> * Update main.yml Co-authored-by: paitrault <aymeric.paitrault@inetum.com> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
c14eafd63f
commit
c69e4f4ac9
6 changed files with 256 additions and 0 deletions
2
tests/integration/targets/gitlab_branch/aliases
Normal file
2
tests/integration/targets/gitlab_branch/aliases
Normal file
|
@ -0,0 +1,2 @@
|
|||
shippable/posix/group1
|
||||
disabled
|
|
@ -0,0 +1,2 @@
|
|||
gitlab_branch: ansible_test_branch
|
||||
gitlab_project_name: ansible_test_project
|
64
tests/integration/targets/gitlab_branch/tasks/main.yml
Normal file
64
tests/integration/targets/gitlab_branch/tasks/main.yml
Normal file
|
@ -0,0 +1,64 @@
|
|||
####################################################################
|
||||
# WARNING: These are designed specifically for Ansible tests #
|
||||
# and should not be used as examples of how to write Ansible roles #
|
||||
####################################################################
|
||||
|
||||
- name: Install required libs
|
||||
pip:
|
||||
name: python-gitlab
|
||||
state: present
|
||||
|
||||
- name: Create {{ gitlab_project_name }}
|
||||
gitlab_project:
|
||||
server_url: "{{ gitlab_host }}"
|
||||
validate_certs: False
|
||||
login_token: "{{ gitlab_login_token }}"
|
||||
name: "{{ gitlab_project_name }}"
|
||||
initialize_with_readme: True
|
||||
state: present
|
||||
|
||||
- name: Create branch {{ gitlab_branch }}
|
||||
community.general.gitlab_branch:
|
||||
api_url: https://gitlab.com
|
||||
api_token: secret_access_token
|
||||
project: "{{ gitlab_project_name }}"
|
||||
branch: "{{ gitlab_branch }}"
|
||||
ref_branch: main
|
||||
state: present
|
||||
|
||||
- name: Create branch {{ gitlab_branch }} ( Idempotency test )
|
||||
community.general.gitlab_branch:
|
||||
api_url: https://gitlab.com
|
||||
api_token: secret_access_token
|
||||
project: "{{ gitlab_project_name }}"
|
||||
branch: "{{ gitlab_branch }}"
|
||||
ref_branch: main
|
||||
state: present
|
||||
register: create_branch
|
||||
|
||||
- name: Test module is idempotent
|
||||
assert:
|
||||
that:
|
||||
- create_branch is not changed
|
||||
|
||||
- name: Cleanup branch {{ gitlab_branch }}
|
||||
community.general.gitlab_branch:
|
||||
api_url: https://gitlab.com
|
||||
api_token: secret_access_token
|
||||
project: "{{ gitlab_project_name }}"
|
||||
branch: "{{ gitlab_branch }}"
|
||||
state: absent
|
||||
register: delete_branch
|
||||
|
||||
- name: Test module is idempotent
|
||||
assert:
|
||||
that:
|
||||
- delete_branch is changed
|
||||
|
||||
- name: Clean up {{ gitlab_project_name }}
|
||||
gitlab_project:
|
||||
server_url: "{{ gitlab_host }}"
|
||||
validate_certs: False
|
||||
login_token: "{{ gitlab_login_token }}"
|
||||
name: "{{ gitlab_project_name }}"
|
||||
state: absent
|
Loading…
Add table
Add a link
Reference in a new issue