forked from cncgoko/Goko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
38 lines (30 loc) · 1.02 KB
/
deploy.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
#!/bin/bash
renameFolders(){
echo "Renaming folder $1 to $2"
curl -u $VAR1:$VAR2 $TARGET/$UPDATE_FOLDER/ -Q "-RNFR $1" -Q "-RNTO $2"
}
# Archive the distant repository
archiveRepository(){
echo "Archiving repository..."
timestamp=`date +"%Y%m%d%H%M%S"`
archivedRepoName=$gokoVersion"_"$timestamp
curl -u $VAR1:$VAR2 $TARGET/$UPDATE_FOLDER/ -Q "-RNFR $gokoVersion" -Q "-RNTO $archivedRepoName"
}
# Export the built repository to destination
exportRepository(){
echo "Exporting repository..."
# Switch to repository build location
cd $TRAVIS_BUILD_DIR/org.goko.build.product/target/repository/
find . -type f -exec curl --ftp-create-dirs -T {} -u $VAR1:$VAR2 $TARGET/$UPDATE_FOLDER/$gokoVersion/{} \;
}
# Let's do it
if [ $updateRepository == 'true' ]
then
if curl -u $VAR1:$VAR2 --output /dev/null --silent --head --fail "$TARGET/$UPDATE_FOLDER/$gokoVersion/"; then
# previous repo already exists, let's archive it
archiveRepository
fi
exportRepository
else
echo "Skipped repository export..."
fi