Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bx_login.sh #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions bx_login.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,24 @@ if [ -z $CF_SPACE ]; then
CF_SPACE="$BLUEMIX_SPACE"
fi


if [ -z "$BLUEMIX_USER" ] || [ -z "$BLUEMIX_PASSWORD" ] || [ -z "$BLUEMIX_ACCOUNT" ]; then
#Check for api key or PW
if [[ -z "$BLUEMIX_USER" || -z "$BLUEMIX_PASSWORD" || -z "$BLUEMIX_ACCOUNT" ]] && [ -z "$BLUEMIX_API_KEY" ]; then
echo "Define all required environment variables and rerun the stage."
exit 1
fi
echo "Deploy pods"

echo "bx login -a $CF_TARGET_URL"
bx login -a "$CF_TARGET_URL" -u "$BLUEMIX_USER" -p "$BLUEMIX_PASSWORD" -c "$BLUEMIX_ACCOUNT" -o "$CF_ORG" -s "$CF_SPACE"

# Use API_KEY if exists
if [ -n "$BLUMEIX_API_KEY" ]; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a spelling mistake here: Should be BLUEMIX_API_KEY

echo "Logging in with API key"
bx login -a "$CF_TARGET_URL" --apikey "$BLUEMIX_API_KEY" -o "$CF_ORG" -s "$CF_SPACE"
else
echo "Logging in with user credentials"
bx login -a "$CF_TARGET_URL" -u "$BLUEMIX_USER" -p "$BLUEMIX_PASSWORD" -c "$BLUEMIX_ACCOUNT" -o "$CF_ORG" -s "$CF_SPACE"
fi

if [ $? -ne 0 ]; then
echo "Failed to authenticate to Bluemix"
exit 1
Expand Down