-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.sh
62 lines (50 loc) · 1.76 KB
/
config.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
if [ -n "$ADDITIONAL_PLUGINS" ]; then
echo "Additional plugins requested: $ADDITIONAL_PLUGINS"
/usr/local/bin/install-plugins.sh $ADDITIONAL_PLUGINS
else
echo "No additional plugins specified.."
fi
sh -c /usr/local/bin/jenkins.sh &
JENKINS_STARTING_TEXT="Please wait while Jenkins is getting ready to work"
while true; do
echo "Waiting for Jenkins to respond..."
curl -s "http://localhost:8080/cli/" > /dev/null
if [ "$?" -eq "0" ]; then
break
fi
sleep 1
done
while true; do
echo "Waiting for Jenkins to be fully up and running..."
curl -s "http://localhost:8080/cli/" | grep "${JENKINS_STARTING_TEXT}" > /dev/null
if [ "$?" -ne "0" ]; then
break
fi
sleep 1
done
if [ -d ${SEED_JOB_WORKSPACE_DIR} ]; then
echo "Folder ${SEED_JOB_WORKSPACE_DIR} seems to exist, the folder contains:"
ls -la $SEED_JOB_WORKSPACE_DIR
else
echo "Folder ${SEED_JOB_WORKSPACE_DIR} doesn't exist, let's create it.."
mkdir -p ${SEED_JOB_WORKSPACE_DIR}
fi
# Check if seed workspace is empty
LINES_OF_FILES_IN_SEED_WORKSPACE=`ls -A ${SEED_JOB_WORKSPACE_DIR} | wc -w | awk {'print $1'}`
echo "Number of files in workspace: ${LINES_OF_FILES_IN_SEED_WORKSPACE}"
# Copy all demo files if workspace is empty
if [ "${LINES_OF_FILES_IN_SEED_WORKSPACE}" -eq "0" ]; then
echo "Copying demo files to workspace dir..."
cp -r ${DEMO_JOB_DIR}* ${SEED_JOB_WORKSPACE_DIR}
fi
# Check for file changes every second:
OLD_VALUE=""
while true; do
NEW_VALUE=`(ls -lFR ${SEED_JOB_WORKSPACE_DIR} | grep -E '.*[^/:]$' | grep -v -E 'total \d+' | awk '{print $6 $7 $8 $9}' | tr '\n' '-')`
if [ "${OLD_VALUE}" != "${NEW_VALUE}" ]; then
curl -s -X POST localhost:8080/job/seed/build --user admin:admin > /dev/null
OLD_VALUE=$NEW_VALUE
echo "\nRan seed at " `date`
fi
sleep 1
done