From bd69a2aa7b70875f3c988e269706b22fefbef40e Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Wed, 8 Apr 2020 14:01:08 -0700 Subject: [PATCH] build(java): fix retry_with_backoff when -e option set (#475) --- .../gcp/templates/java_library/.kokoro/common.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/synthtool/gcp/templates/java_library/.kokoro/common.sh b/synthtool/gcp/templates/java_library/.kokoro/common.sh index a3bbc5f67..8f09de5d3 100644 --- a/synthtool/gcp/templates/java_library/.kokoro/common.sh +++ b/synthtool/gcp/templates/java_library/.kokoro/common.sh @@ -13,18 +13,28 @@ # See the License for the specific language governing permissions and # limitations under the License. -# set -eo pipefail - function retry_with_backoff { attempts_left=$1 sleep_seconds=$2 shift 2 command=$@ + + # store current flag state + flags=$- + + # allow a failures to continue + set +e echo "${command}" ${command} exit_code=$? + # restore "e" flag + if [[ ${flags} =~ e ]] + then set -e + else set +e + fi + if [[ $exit_code == 0 ]] then return 0