-
Notifications
You must be signed in to change notification settings - Fork 0
/
getproject
executable file
·55 lines (52 loc) · 1.64 KB
/
getproject
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
#!/bin/bash
# getproject PROJECTs...
#
# If on a Jenkins server, enter the project path below and this script will pull sources from the project path, otherwise it will try to git clone/pull. If cloning, you will need to enter the full http repo.
: ${PROJECTPATH:=/var/lib/jenkins/jobs}
: ${SOURCES:=sources}
if [ $# -eq 0 ]; then
echo "Error: invalid syntax"
echo "getproject <PROJECTs>..."
fi
if [ ! -d "$SOURCES" ]; then
mkdir "$SOURCES"
fi
for projname in $@; do
if [ -d $PROJECTPATH ]; then
project=`ls $PROJECTPATH | grep "${projname}-src"`
if [ -n "$project" ]; then
if [ -d "$PROJECTPATH/$project/workspace/source" ]; then
if [ -d "$SOURCES/$projname" ]; then
rm -rf "$SOURCES/$projname"
fi
printf "Get $projname ... "
cp -r "$PROJECTPATH/$project/workspace/source" "$SOURCES/$projname"
echo "[done]"
else
echo Error: $PROJECTPATH/$project/workspace/source does not exist
fi
else
cd "$SOURCES"
git clone $projname
proj=`basename $projname`
if [ ! -d "$SOURCES/$proj" ]; then
echo "Error: $1 not found"
fi
cd -
fi
else
proj=`basename $projname`
if [ -d "$SOURCES/$proj" ]; then
cd "$SOURCES/$proj"
git pull
cd -
else
cd "$SOURCES"
git clone $projname
if [ ! -d "$proj" ]; then
echo Error: $1 was not found
fi
cd -
fi
fi
done