forked from MatousJobanek/che-e2e-tests
-
Notifications
You must be signed in to change notification settings - Fork 1
/
prepare_environment.sh
executable file
·63 lines (59 loc) · 1.76 KB
/
prepare_environment.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -x
set -e
# We need to disable selinux for now
/usr/sbin/setenforce 0
# Get all the deps in
yum -y install \
docker \
make \
git
service docker start
# Fetch PR and rebase on master, if job runs from PR
cat jenkins-env \
| grep -E "(ghprbSourceBranch|ghprbPullId)=" \
| sed 's/^/export /g' \
> /tmp/jenkins-env
source /tmp/jenkins-env
if [[ ! -z "${ghprbPullId}" ]] && [[ ! -z "${ghprbSourceBranch}" ]]; then
echo 'Checking out to Github PR branch'
git fetch origin pull/${ghprbPullId}/head:${ghprbSourceBranch}
git checkout ${ghprbSourceBranch}
git fetch origin master
git rebase FETCH_HEAD
else
echo 'Working on current branch of EE tests repo'
fi
# Set credentials
set +x
cat jenkins-env \
| grep -E "(OSIO|KEYCLOAK)" \
| sed 's/^/export /g' \
> credential_file
source credential_file
if [[ -z "${OSIO_USERNAME}" ]]; then
empty_credentials="OSIO username is empty, "
fi
if [[ -z "${OSIO_PASSWORD}" ]]; then
empty_credentials=${empty_credentials}"OSIO password is empty, "
fi
if [[ -z "${KEYCLOAK_TOKEN}" ]]; then
empty_credentials=${empty_credentials}"Keycloak token is empty"
fi
if [[ ! -z "${empty_credentials}" ]]; then
echo ${empty_credentials}
exit 1
else
echo 'OpenShift username and password and Keycloak token are not empty.'
fi
if [[ $(curl -X GET -H "Authorization: Bearer ${KEYCLOAK_TOKEN}" https://sso.openshift.io/auth/realms/fabric8/broker/openshift-v3/token \
| grep access_token | wc -l) -ne 1 ]]; then
echo "Keycloak token is expired"
exit 1
else
echo "Keycloak token is alive. Proceeding with EE tests."
fi
echo 'export OSIO_USERNAME='${OSIO_USERNAME} >> ./env-vars
echo 'export OSIO_PASSWORD='${OSIO_PASSWORD} >> ./env-vars
echo 'export KEYCLOAK_TOKEN='${KEYCLOAK_TOKEN} >> ./env-vars
set -x