| |
@@ -1,17 +1,37 @@
|
| |
- set_fact:
|
| |
job_vars_name: "{{ job_vars.name | default(image_name) }}"
|
| |
|
| |
- - name: Build config for trigger update for {{ job_vars_name }}
|
| |
+ - name: "{{ job_vars_name }}: Check BuildConfig change"
|
| |
k8s:
|
| |
namespace: "{{ c3i_ocp_namespace }}"
|
| |
state: present
|
| |
definition: "{{ lookup('template', job_vars.template) }}"
|
| |
- vars:
|
| |
- c3i_trigger_update_only: true
|
| |
+ register: build_update
|
| |
|
| |
- - name: Update triggers for {{ job_vars_name }}
|
| |
- shell: "oc start-build --wait -n {{ c3i_ocp_namespace }} {{ job_vars_name }}"
|
| |
- register: result
|
| |
+ # Reconfiguration of Jenkins job to set Trigger section properly:
|
| |
+ # 1) Configure Jenkins Job to run on master node and stages part is replaced by noop stages part.
|
| |
+ # 2) Jenkins Job is executed and triggers are set on the job.
|
| |
+ # 3) Build run from noop stages is removed.
|
| |
+ # 4) Jenkins Job is reconfigured with final configuration.
|
| |
+ - block:
|
| |
+ - name: "{{ job_vars_name }}: Update BuildConfig to be run on master and without stages"
|
| |
+ k8s:
|
| |
+ namespace: "{{ c3i_ocp_namespace }}"
|
| |
+ state: present
|
| |
+ definition: "{{ lookup('template', job_vars.template) }}"
|
| |
+ vars:
|
| |
+ c3i_trigger_update_only: true
|
| |
|
| |
- - name: Delete triggers update build for {{ job_vars_name }}
|
| |
- shell: "oc -n {{ c3i_ocp_namespace }} delete {{ result.stdout_lines[0].split()[0] }}"
|
| |
+ - name: "{{ job_vars_name }}: Run BuildConfig to enable triggers"
|
| |
+ shell: "oc start-build --wait -n {{ c3i_ocp_namespace }} {{ job_vars_name }}"
|
| |
+ register: result
|
| |
+
|
| |
+ - name: "{{ job_vars_name }}: Delete generated build from the previous step"
|
| |
+ shell: "oc -n {{ c3i_ocp_namespace }} delete {{ result.stdout_lines[0].split()[0] }}"
|
| |
+
|
| |
+ - name: "{{ job_vars_name }}: Recover original BuildConfig"
|
| |
+ k8s:
|
| |
+ namespace: "{{ c3i_ocp_namespace }}"
|
| |
+ state: present
|
| |
+ definition: "{{ lookup('template', job_vars.template) }}"
|
| |
+ when: build_update.changed
|
| |