First delete all pipelines, before adding 1.
This commit is contained in:
parent
bd78efb905
commit
4f24f199dc
86
gitlab.yml
86
gitlab.yml
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env ansible-playbook
|
#!/usr/bin/env ansible-playbook
|
||||||
---
|
---
|
||||||
- name: configure GitLab repository
|
- name: configure gitlab repository
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
become: no
|
become: no
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
|
@ -24,40 +24,56 @@
|
||||||
set_fact:
|
set_fact:
|
||||||
encoded_path: "{{ namespace + '%2F' + role }}"
|
encoded_path: "{{ namespace + '%2F' + role }}"
|
||||||
|
|
||||||
- name: place variable
|
# - name: place variable
|
||||||
block:
|
# block:
|
||||||
- name: see if the variable is set already
|
# - name: see if the variable is set already
|
||||||
uri:
|
# uri:
|
||||||
url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/variables"
|
# url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/variables"
|
||||||
method: GET
|
# method: GET
|
||||||
body_format: json
|
# body_format: json
|
||||||
headers:
|
# headers:
|
||||||
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
# PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
||||||
body:
|
# body:
|
||||||
key: "GALAXY_API_KEY"
|
# key: "GALAXY_API_KEY"
|
||||||
register: check_variable
|
# register: check_variable
|
||||||
failed_when:
|
# failed_when:
|
||||||
check_variable.json | length <= 0
|
# check_variable.json | length <= 0
|
||||||
rescue:
|
# rescue:
|
||||||
- name: place variable
|
# - name: place variable
|
||||||
uri:
|
# uri:
|
||||||
url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/variables"
|
# url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/variables"
|
||||||
method: POST
|
# method: POST
|
||||||
body_format: json
|
# body_format: json
|
||||||
status_code:
|
# status_code:
|
||||||
- 201
|
# - 201
|
||||||
headers:
|
# headers:
|
||||||
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
# PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
||||||
body:
|
# body:
|
||||||
key: "GALAXY_API_KEY"
|
# key: "GALAXY_API_KEY"
|
||||||
value: "{{ galaxy_api_key }}"
|
# value: "{{ galaxy_api_key }}"
|
||||||
variable_type: env_var
|
# variable_type: env_var
|
||||||
protects: true
|
# protects: true
|
||||||
masked: true
|
# masked: true
|
||||||
|
|
||||||
- name: show details
|
- name: list pipelines
|
||||||
debug:
|
uri:
|
||||||
msg: "Scheduling {{ role }} on {{ letter_minute_mapping[role[13]] }} {{ letter_hour_mapping[role[13]] }} {{ letter_day_mapping[role[13]] }} * *"
|
url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/pipeline_schedules"
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
||||||
|
register: gitlab_schedules
|
||||||
|
|
||||||
|
- name: delete all pipelines
|
||||||
|
uri:
|
||||||
|
url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/pipeline_schedules/{{ item.id }}"
|
||||||
|
method: DELETE
|
||||||
|
headers:
|
||||||
|
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
||||||
|
status_code:
|
||||||
|
- 204
|
||||||
|
loop: "{{ gitlab_schedules.json }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.id }}"
|
||||||
|
|
||||||
- name: create a new pipeline schedule
|
- name: create a new pipeline schedule
|
||||||
uri:
|
uri:
|
||||||
|
|
@ -71,5 +87,5 @@
|
||||||
body:
|
body:
|
||||||
description: "Monthly test"
|
description: "Monthly test"
|
||||||
ref: master
|
ref: master
|
||||||
cron: '{{ letter_minute_mapping[role[13]] }} {{ letter_hour_mapping[role[13]] }} {{ letter_day_mapping[role[13]] }} * *'
|
cron: "{{ letter_minute_mapping[role[15]] | default('13') }} {{ letter_hour_mapping[role[13]] }} {{ letter_day_mapping[role[13]] }} * *"
|
||||||
cron_timezone: Amsterdam
|
cron_timezone: Amsterdam
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue