Skip to content

Commit

Permalink
Merge pull request #74 from kubenow/feature/release_script
Browse files Browse the repository at this point in the history
Keep image when testing a tag
  • Loading branch information
mcapuccini authored Jan 19, 2017
2 parents 21daecc + b06596b commit 0ba2010
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
7 changes: 6 additions & 1 deletion test/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/roles/test-core/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 15 additions & 5 deletions test/roles/test-packer/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 0ba2010

Please sign in to comment.