diff --git a/appengine/endpoints-frameworks-v2/discovery/jenkins.sh b/appengine/endpoints-frameworks-v2/discovery/jenkins.sh old mode 100644 new mode 100755 index dcf31626e50..3bc1515636c --- a/appengine/endpoints-frameworks-v2/discovery/jenkins.sh +++ b/appengine/endpoints-frameworks-v2/discovery/jenkins.sh @@ -22,16 +22,19 @@ function TestEndpoints () { # Test getGreeting Endpoint (hello world!) curl -X GET \ "https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/0" | \ + tee "$ERROR_OUTPUT_DIR/response.json" | \ grep "hello version-${2}" # Test getGreeting Endpoint (goodbye world!) curl -X GET \ "https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/1" | \ + tee "$ERROR_OUTPUT_DIR/response.json" | \ grep "goodbye world!" # Test listGreeting Endpoint (hello world! and goodbye world!) curl -X GET \ "https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting" | \ + tee "$ERROR_OUTPUT_DIR/response.json" | \ grep "hello world!\|goodbye world!" # Test multiply Endpoint (This is a greeting.) @@ -39,6 +42,7 @@ function TestEndpoints () { -H "Content-Type: application/json" \ --data "{'message':'This is a greeting from instance ${2}'}." \ "https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/1" | \ + tee "$ERROR_OUTPUT_DIR/response.json" | \ grep "This is a greeting from instance ${2}." } diff --git a/appengine/endpoints-frameworks-v2/discovery/src/main/java/com/example/helloendpoints/Greetings.java b/appengine/endpoints-frameworks-v2/discovery/src/main/java/com/example/helloendpoints/Greetings.java index 69cbb4b9df1..11f533f622d 100644 --- a/appengine/endpoints-frameworks-v2/discovery/src/main/java/com/example/helloendpoints/Greetings.java +++ b/appengine/endpoints-frameworks-v2/discovery/src/main/java/com/example/helloendpoints/Greetings.java @@ -43,7 +43,7 @@ public class Greetings { public static ArrayList greetings = new ArrayList(); static { - greetings.add(new HelloGreeting("hello version-jerjou-test!")); + greetings.add(new HelloGreeting("hello world!")); greetings.add(new HelloGreeting("goodbye world!")); } //[END api_def] diff --git a/flexible/sparkjava/jenkins.sh b/flexible/sparkjava/jenkins.sh index fe1644dd79f..6d4c710f9fb 100755 --- a/flexible/sparkjava/jenkins.sh +++ b/flexible/sparkjava/jenkins.sh @@ -21,6 +21,7 @@ set -xe function runtests () { curl -X GET \ "https://${2}-dot-${1}.appspot.com/api/users" | \ + tee "$ERROR_OUTPUT_DIR/response.json" | \ grep "^\\[" } diff --git a/jenkins.sh b/jenkins.sh index a8b7ad6dd08..b6c6ff579ee 100755 --- a/jenkins.sh +++ b/jenkins.sh @@ -19,43 +19,58 @@ shopt -s globstar # We spin up some subprocesses. Don't kill them on hangup trap '' HUP -app_version="" +# Temporary directory to store any output to display on error +export ERROR_OUTPUT_DIR +ERROR_OUTPUT_DIR="$(mktemp -d)" +trap 'rm -r "${ERROR_OUTPUT_DIR}"' EXIT -# shellcheck disable=SC2120 delete_app_version() { yes | gcloud --project="${GOOGLE_PROJECT_ID}" \ app versions delete "${1}" } + handle_error() { errcode=$? # Remember the error code so we can exit with it after cleanup - # Clean up - delete_app_version "$@" + # Clean up remote app version + delete_app_version "${1}" & + + # Display any errors + if [ -n "$(find "${2}" -mindepth 1 -print -quit)" ]; then + cat "${2:?}"/* 1>&2 + fi + + wait exit ${errcode} } +cleanup() { + delete_app_version "${GOOGLE_VERSION_ID}" & + rm -r "${ERROR_OUTPUT_DIR:?}/"* +} + # First, style-check the shell scripts shellcheck ./**/*.sh # Find all jenkins.sh's and run them. find . -mindepth 2 -maxdepth 5 -name jenkins.sh -type f | while read -r path; do dir="${path%/jenkins.sh}" - # Use just the first letter of each subdir in version name + # Need different app versions because flex can't deploy over an existing + # version. Use just the first letter of each subdir in version name + export GOOGLE_VERSION_ID # shellcheck disable=SC2001 - app_version="jenkins-$(echo "${dir#./}" | sed 's#\([a-z]\)[^/]*/#\1-#g')" + GOOGLE_VERSION_ID="jenkins-$(echo "${dir#./}" | sed 's#\([a-z]\)[^/]*/#\1-#g')" - trap 'handle_error $app_version' ERR + trap 'handle_error "${GOOGLE_VERSION_ID}" "${ERROR_OUTPUT_DIR}"' ERR ( # If there's an error, clean up pushd "${dir}" - # Need different app versions because flex can't deploy over an existing - # version - GOOGLE_VERSION_ID="${app_version}" /bin/bash ./jenkins.sh + /bin/bash ./jenkins.sh - # Clean up the app version in the background - delete_app_version "${app_version}" & + # Clean up the app version + cleanup ) # Clear the trap trap - ERR