diff --git a/test/integration-test.yml b/test/integration-test.yml index ff9ea3b8..76832e65 100644 --- a/test/integration-test.yml +++ b/test/integration-test.yml @@ -9,8 +9,13 @@ - 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('.', '')}}" + - 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: - test-packer - test-terraform 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 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)