3 # This file is intended to be sourced with `. shared.sh` or
4 # `source shared.sh`, hence the invalid shebang and not being
5 # marked as an executable file in git.
7 # See http://unix.stackexchange.com/questions/82598
8 # Duplicated in docker/dist-various-2/shared.sh
10 echo "Attempting with retry:" "$@"
15 if [[ $n -lt $max ]]; then
16 sleep $n # don't retry immediately
18 echo "Command failed. Attempt $n/$max:"
20 echo "The command has failed after $n attempts."
28 [ "$CI" = "true" ] || [ "$TRAVIS" = "true" ] || [ "$TF_BUILD" = "True" ]
32 [ "$TRAVIS_OS_NAME" = "osx" ] || [ "$AGENT_OS" = "Darwin" ]
35 function getCIBranch {
36 if [ "$TRAVIS" = "true" ]; then
38 elif [ "$APPVEYOR" = "True" ]; then
39 echo "$APPVEYOR_REPO_BRANCH"
41 echo "$BUILD_SOURCEBRANCHNAME"
45 if ! declare -F travis_fold; then
46 if [ "${TRAVIS-false}" = 'true' ]; then
47 # This is a trimmed down copy of
48 # https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh
50 echo -en "travis_fold:$1:$2\r\033[0K"
53 travis_timer_id=$(printf %08x $(( RANDOM * RANDOM )))
54 travis_start_time=$(travis_nanoseconds)
55 echo -en "travis_time:start:$travis_timer_id\r\033[0K"
57 travis_time_finish() {
58 travis_end_time=$(travis_nanoseconds)
59 local duration=$(($travis_end_time-$travis_start_time))
60 local msg="travis_time:end:$travis_timer_id"
61 echo -en "\n$msg:start=$travis_start_time,finish=$travis_end_time,duration=$duration\r\033[0K"
63 if [ $(uname) = 'Darwin' ]; then
64 travis_nanoseconds() {
65 date -u '+%s000000000'
68 travis_nanoseconds() {
73 travis_fold() { return 0; }
74 travis_time_start() { return 0; }
75 travis_time_finish() { return 0; }