From d3e13c7d93aaa671376a787c0d950a7a476dd9af Mon Sep 17 00:00:00 2001 From: Marco Capuccini Date: Thu, 19 Jan 2017 11:25:31 +0100 Subject: [PATCH 1/3] keep the image when building a tag --- test/integration-test.yml | 7 +++++++ test/roles/test-packer/handlers/main.yml | 20 +++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/test/integration-test.yml b/test/integration-test.yml index ff9ea3b8..1eebd5d4 100644 --- a/test/integration-test.yml +++ b/test/integration-test.yml @@ -11,7 +11,14 @@ register: git_describe - set_fact: current_version: "v{{git_describe.stdout | replace('\n','') | replace('.', '')}}" + - set_fact: + keep_image: true + when: current_version | match("^v[0-9]{3}([ab][0-9]{1,}|rc[0-9]{1,})?$") roles: - test-packer - test-terraform - test-core + post_tasks: + - name: "tests passed flag" + set_fact: + tests_passed: true diff --git a/test/roles/test-packer/handlers/main.yml b/test/roles/test-packer/handlers/main.yml index 11340d61..700ef53d 100644 --- a/test/roles/test-packer/handlers/main.yml +++ b/test/roles/test-packer/handlers/main.yml @@ -6,30 +6,40 @@ awk '{print $2;}' | tr -d "\n" register: get_image_id - when: host_cloud == "openstack" + when: + - host_cloud == "openstack" + - (keep_image is not defined) or (tests_passed is not defined) - name: "delete packer image (openstack)" listen: "delete image" command: glance image-delete {{get_image_id.stdout}} - when: host_cloud == "openstack" + when: + - host_cloud == "openstack" + - (keep_image is not defined) or (tests_passed is not defined) - name: "delete packer image (gce)" listen: "delete image" command: > gcloud compute images delete 'kubenow-{{current_version}}' -q - when: host_cloud == "gce" + when: + - host_cloud == "gce" + - (keep_image is not defined) or (tests_passed is not defined) - name: "deregister packer image (aws)" listen: "delete image" command: > aws ec2 deregister-image --image-id {{aws_ami_id}} - when: host_cloud == "aws" + when: + - host_cloud == "aws" + - (keep_image is not defined) or (tests_passed is not defined) - name: "delete packer snapshot (aws)" listen: "delete image" command: > aws ec2 delete-snapshot --snapshot-id {{aws_snap_id}} - when: host_cloud == "aws" + when: + - host_cloud == "aws" + - (keep_image is not defined) or (tests_passed is not defined) From adad796a282934b94a4a19c04cbaf62fc1b188a0 Mon Sep 17 00:00:00 2001 From: Marco Capuccini Date: Thu, 19 Jan 2017 11:50:41 +0100 Subject: [PATCH 2/3] improve task names --- test/integration-test.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/integration-test.yml b/test/integration-test.yml index 1eebd5d4..a10a3184 100644 --- a/test/integration-test.yml +++ b/test/integration-test.yml @@ -9,9 +9,11 @@ - name: get KubeNow version (git describe --tags --always) command: git describe --tags --always register: git_describe - - set_fact: + - name: "set version name" + set_fact: current_version: "v{{git_describe.stdout | replace('\n','') | replace('.', '')}}" - - set_fact: + - name: "set keep_image flag" + set_fact: keep_image: true when: current_version | match("^v[0-9]{3}([ab][0-9]{1,}|rc[0-9]{1,})?$") roles: @@ -19,6 +21,6 @@ - test-terraform - test-core post_tasks: - - name: "tests passed flag" + - name: "set tests_passed flag" set_fact: tests_passed: true From b06596b8a33785c44b5b990f549901c8c878c16b Mon Sep 17 00:00:00 2001 From: Marco Capuccini Date: Thu, 19 Jan 2017 12:48:33 +0100 Subject: [PATCH 3/3] move passed flag in role --- test/integration-test.yml | 4 ---- test/roles/test-core/tasks/main.yml | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/integration-test.yml b/test/integration-test.yml index a10a3184..76832e65 100644 --- a/test/integration-test.yml +++ b/test/integration-test.yml @@ -20,7 +20,3 @@ - test-packer - test-terraform - test-core - post_tasks: - - name: "set tests_passed flag" - set_fact: - tests_passed: true diff --git a/test/roles/test-core/tasks/main.yml b/test/roles/test-core/tasks/main.yml index 498ebaa2..09198a84 100644 --- a/test/roles/test-core/tasks/main.yml +++ b/test/roles/test-core/tasks/main.yml @@ -25,3 +25,7 @@ # Timeout to avoid travis to kill the whole job async: 550 poll: 10 + +- name: "set tests_passed flag" + set_fact: + tests_passed: true