From b15d73a05b98119176fce229032aa55daa7f269b Mon Sep 17 00:00:00 2001 From: manuedelf Date: Wed, 27 Jul 2022 22:09:47 +0200 Subject: [PATCH] Gitlab CI/CD settings configuration. Add the possibility to set variables for CI/CD on level project. Signed-off-by: manuedelf --- defaults/main.yml | 2 ++ tasks/debian.yml | 6 ++++++ tasks/gitlab.yml | 9 +++++++++ tasks/redhat.yml | 6 ++++++ 4 files changed, 23 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index c580d0e..396e055 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -179,6 +179,8 @@ gitlab_privaterunner_image: alpine:latest gitlab_privaterunner_network_mode: bridge # or host gitlab_ci_mode: "overwrite" # or insert gitlab_use_chainedci: false +gitlab_ci_variables: [] +purge_gitlab_ci_variables: false # s3 publish_to_s3: true diff --git a/tasks/debian.yml b/tasks/debian.yml index e3eb487..6a020c3 100644 --- a/tasks/debian.yml +++ b/tasks/debian.yml @@ -181,6 +181,12 @@ when: - gitlab_deploy or gitlab_configure - ansible_python.version.major==3 +- name: Installing python-gitlab via pip + become: "{{ not lookup('env','VIRTUAL_ENV') }}" + pip: + name: python-gitlab + when: + - gitlab_deploy or gitlab_configure - name: Installing git become: true apt: diff --git a/tasks/gitlab.yml b/tasks/gitlab.yml index cb7489d..dc5026f 100644 --- a/tasks/gitlab.yml +++ b/tasks/gitlab.yml @@ -525,3 +525,12 @@ when: - gitlab_configure - gitlab_create_jobs +- name: Set or update CI/CD variables + community.general.gitlab_project_variable: + api_url: '{{ gitlab_url }}' + api_oauth_token: '{{ oauth.json.access_token }}' + project: 'xtesting/{{ project }}' + purge: '{{ purge_gitlab_ci_variables }}' + variables: '{{ gitlab_ci_variables }}' + when: + - gitlab_configure \ No newline at end of file diff --git a/tasks/redhat.yml b/tasks/redhat.yml index 33f0eb0..6c6259c 100644 --- a/tasks/redhat.yml +++ b/tasks/redhat.yml @@ -197,6 +197,12 @@ when: - gitlab_deploy or gitlab_configure - ansible_python.version.major==3 +- name: Installing python-gitlab via pip + become: "{{ not lookup('env','VIRTUAL_ENV') }}" + pip: + name: python-gitlab + when: + - gitlab_deploy or gitlab_configure - name: Installing git become: true yum: