Skip to content

Instantly share code, notes, and snippets.

@mesmacosta
Last active September 7, 2019 19:28
Show Gist options
  • Select an option

  • Save mesmacosta/09a2f73ba5418cf3cd0cd84c0b534e3f to your computer and use it in GitHub Desktop.

Select an option

Save mesmacosta/09a2f73ba5418cf3cd0cd84c0b534e3f to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "Beginning Entrypoint script execution."
output=$(behave ./features --tags=-wip)
status=$?
echo "Behave finished executing."
# Change this to your project
gcloud config set project YOUR_PROJECT
# Add this service account to the root of your source repo dir. It's a SA with the Log writter and Custom VM delete Role.
gcloud auth activate-service-account --key-file=/app/auth/batch-workload-sa.json
gcloud logging write batch-workload "[$(hostname)]Exit status from behave cmd: $status"
gcloud logging write batch-workload "[$(hostname)]Output from behave cmd: $output"
echo "Entrypoint script execution finished."
# Delete the VM
gcp_zone=$(curl -H Metadata-Flavor:Google http://metadata.google.internal/computeMetadata/v1/instance/zone -s | cut -d/ -f4)
gcloud compute instances delete $(hostname) --zone ${gcp_zone}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment