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 export MIRRORS_BASE
="https://ci-mirrors.rust-lang.org/rustc"
9 # See http://unix.stackexchange.com/questions/82598
10 # Duplicated in docker/dist-various-2/shared.sh
12 echo "Attempting with retry:" "$@"
17 if [[ $n -lt $max ]]; then
18 sleep $n # don't retry immediately
20 echo "Command failed. Attempt $n/$max:"
22 echo "The command has failed after $n attempts."
30 [[ "${CI-false}" = "true" ]] || isAzurePipelines || isGitHubActions
33 function isAzurePipelines
{
34 [[ "${TF_BUILD-False}" = "True" ]]
37 function isGitHubActions
{
38 [[ "${GITHUB_ACTIONS-false}" = "true" ]]
42 [[ "${OSTYPE}" = "darwin"* ]]
46 [[ "${OSTYPE}" = "cygwin" ]] ||
[[ "${OSTYPE}" = "msys" ]]
50 [[ "${OSTYPE}" = "linux-gnu" ]]
54 if [[ $# -ne 1 ]]; then
55 echo "usage: $0 <branch-name>"
60 if isAzurePipelines
; then
61 [[ "${BUILD_SOURCEBRANCHNAME}" = "${name}" ]]
62 elif isGitHubActions
; then
63 [[ "${GITHUB_REF}" = "refs/heads/${name}" ]]
65 echo "isCiBranch only works inside CI!"
71 if isAzurePipelines
; then
72 echo "${BUILD_SOURCEVERSION}"
73 elif isGitHubActions
; then
76 echo "ciCommit only works inside CI!"
81 function ciCheckoutPath
{
82 if isAzurePipelines
; then
83 echo "${SYSTEM_WORKFOLDER}"
84 elif isGitHubActions
; then
85 echo "${GITHUB_WORKSPACE}"
87 echo "ciCheckoutPath only works inside CI!"
92 function ciCommandAddPath
{
93 if [[ $# -ne 1 ]]; then
94 echo "usage: $0 <path>"
99 if isAzurePipelines
; then
100 echo "##vso[task.prependpath]${path}"
101 elif isGitHubActions
; then
102 echo "::add-path::${value}"
104 echo "ciCommandAddPath only works inside CI!"
109 function ciCommandSetEnv
{
110 if [[ $# -ne 2 ]]; then
111 echo "usage: $0 <name> <value>"
117 if isAzurePipelines
; then
118 echo "##vso[task.setvariable variable=${name}]${value}"
119 elif isGitHubActions
; then
120 echo "::set-env name=${name}::${value}"
122 echo "ciCommandSetEnv only works inside CI!"