forked from openshift/console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins
executable file
·33 lines (27 loc) · 1018 Bytes
/
jenkins
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
#!/bin/bash -e
# This script contains all jenkins work.
# This runs directly on the jenkins build host.
# The Jenkins build command should do nothing but execute this script.
CURRENT_USER=$(whoami)
CURRENT_UID=$(id -u $CURRENT_USER)
echo Running under user: $CURRENT_USER, with uid: $CURRENT_UID
# We assume the jenkins jenkins user with uid 1000 on all build hosts
export BUILDER_RUN_USER=1000
if [ ${BUILDER_RUN_USER} -eq ${CURRENT_UID} ]; then
echo "Running under User: ${CURRENT_USER}, with UID: ${CURRENT_UID}"
else
echo "Expected to run with UID: ${BUILDER_RUN_USER}, instead UID is: ${CURRENT_UID}. Fix Jenkins and try again."
exit 1
fi
set -x
./clean
./builder-run ./build
./builder-run ./test
GIT_SHA_HEAD=$(git rev-parse HEAD)
GIT_SHA_MASTER=$(git rev-parse origin/master)
if [ "$GIT_SHA_HEAD" == "$GIT_SHA_MASTER" ]; then
echo "detected master build. building & pushing images..."
./push
else
echo "skipping image push. HEAD sha does not appear to be master: $GIT_SHA_HEAD"
fi