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:
paytroff 2021-12-09 21:02:58 +01:00 committed by GitHub
parent c14eafd63f
commit c69e4f4ac9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 256 additions and 0 deletions

View file

@ -0,0 +1,2 @@
shippable/posix/group1
disabled

View file

@ -0,0 +1,2 @@
gitlab_branch: ansible_test_branch
gitlab_project_name: ansible_test_project

View 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