Skip to content

Commit 87985fc

Browse files
Merge pull request #16 from splunk/ISSUE-3
Issue 3
2 parents d0bf19c + d41e4e4 commit 87985fc

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@
33
# so set gather_facts to no here, and run setup explicitly in the role
44
gather_facts: no
55
roles:
6+
- role: docker_skip_hosts_in_registry
7+
delegate_to: "{{ groups['docker_build_hosts'] | first }}"
8+
tags:
9+
- never
10+
- skip-if-in-registry
11+
612
- role: docker_build_gather_facts
713
delegate_to: "{{ groups['docker_build_hosts'] | first }}"
14+
when: not skip_build_and_push
815

916
- role: docker_image_build
1017
delegate_to: "{{ groups['docker_build_hosts'] | first }}"
18+
when: not skip_build_and_push

group_vars/all.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ role_build_variants:
4848
- build_vars:
4949
primary_build: false
5050
tag: "{{ version }}-standalone"
51+
52+
# skip_build_and_push is overrideable by using the skip-if-in-registry tag, but defaults to false to always perform the build
53+
skip_build_and_push: false

push.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,12 @@
22
# nothing here should rely on gathered facts
33
gather_facts: no
44
roles:
5+
- role: docker_skip_hosts_in_registry
6+
delegate_to: "{{ groups['docker_build_hosts'] | first }}"
7+
tags:
8+
- never
9+
- skip-if-in-registry
10+
511
- role: docker_image_push
612
delegate_to: "{{ groups['docker_build_hosts'] | first }}"
13+
when: not skip_build_and_push
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
- block:
2+
- name: "check if {{ repository_push_image }} is missing from the registry"
3+
command: "docker manifest inspect {{ repository_push_image }}"
4+
become: "{{ docker_become_user is defined }}"
5+
become_user: "{{ docker_become_user|default(omit) }}"
6+
environment:
7+
DOCKER_CLI_EXPERIMENTAL: enabled
8+
# we don't need to keep checking after clearing skip_build_and_push
9+
# only build variants that are configured to push with this configuration should be checked
10+
when: (build_vars.push_when | default(false)) and skip_build_and_push
11+
12+
# when the image doesn't exist in the registry the above returns a non-zero, causing an exception
13+
rescue:
14+
- name: image is missing, clear skip_build_and_push
15+
set_fact:
16+
skip_build_and_push: false
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- name: set default to skip build and push
2+
set_fact:
3+
skip_build_and_push: true
4+
5+
- name: run clear_skip_if_missing for each variant
6+
include_tasks: clear_skip_if_missing.yml
7+
vars:
8+
build_vars: "{{ build_variant.build_vars }}"
9+
loop: "{{ build_variants }}"
10+
loop_control:
11+
loop_var: build_variant

0 commit comments

Comments
 (0)