Before build, detect whether secrets are available (#217)

* Before checking all the env vars, detect whether secrets, usually encrypted, are available or not. Secrets are not available when building a pull request, so the script will not check for those.
This commit is contained in:
Devis Lucato 2018-05-30 12:22:57 -07:00 коммит произвёл GitHub
Родитель 59347ead63
Коммит 7f4befe616
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -1,7 +1,19 @@
#!/usr/bin/env bash
# Copyright (c) Microsoft. All rights reserved.
if [[ -z "$PCS_IOTHUB_CONNSTRING" ]]; then
# Before checking all the env vars, detect whether secrets, usually encrypted, are available or not.
# Secrets are not available when building a pull request, so the script will not check for those.
detect_secrets() {
SECRETS_AVAILABLE="true"
if [[ "$TRAVIS_PULL_REQUEST" != "" && "$TRAVIS_PULL_REQUEST" != "false" ]]; then
SECRETS_AVAILABLE="false"
echo "Warning: secrets and encrypted variables are not available when testing pull requests."
fi
}
detect_secrets
if [[ -z "$PCS_IOTHUB_CONNSTRING" && "$SECRETS_AVAILABLE" = "true" ]]; then
echo "Error: the PCS_IOTHUB_CONNSTRING environment variable is not defined."
exit 1
fi