Commit c772c45f authored by Antoine Regimbeau's avatar Antoine Regimbeau
Browse files

CI: factorize

parent 22b5e0d6
......@@ -4,6 +4,7 @@
# Configure git for tar.xz
git config tar.tar.xz.command "xz -c"
if [ $CI_COMMIT_REF_NAME = "develop" ] # check if the branch name is develop or not
then # we are on develop
jobs_directory=/home/otbpush/test/$(date +%F)
......@@ -15,31 +16,31 @@ echo "jobs_directory=${jobs_directory}"
# Create today's directory on serveur otb5-vm2
echo "Creating today's directory"
ssh mkdir -p ${jobs_directory}
ssh ${server_name} mkdir -p ${jobs_directory}
# Delete latest
echo "Deleting latest directory"
if [ $CI_COMMIT_REF_NAME = "develop" ]
then # On develop
ssh rm -rf /home/otbpush/test/latest
ssh ${server_name} rm -rf /home/otbpush/test/latest
# Create symilink
ssh ln -s ${jobs_directory} /home/otbpush/test/latest
ssh ${server_name} ln -s ${jobs_directory} /home/otbpush/test/latest
# Cleaning old directory
matching_dirs=$(ls -1 | grep -oE '^20[0-9]{2}-[0-9]{2}-[0-9]{2}$' | sort)
rm -rf $(echo $matching_dirs | tr ' ' '\n' | head -n -${history_length})
else # On release
# Remove what is inside staging area
ssh rm -rf ${jobs_directory}/*
ssh ${server_name} rm -rf ${jobs_directory}/*
# Push package
echo "Pushing binary packages"
scp build_packages/OTB-*.{run,zip}${jobs_directory}/.
scp build_packages/OTB-*.{run,zip} ${server_name}:${jobs_directory}/.
# Push doc
echo "Pushing documentation"
scp build/{CookBook-*-html.tar.gz,\
/Documentation/{Cookbook/latex/CookBook-*.pdf,Doxygen/OTB-Doxygen-*.tar.bz2}} \${jobs_directory}/.
# Create zip, tar.gz and tar.xy source
echo "Creating source tarball and zip"
......@@ -48,16 +49,16 @@ git archive --format=tgz -o OTB-sources-$CI_COMMIT_SHORT_SHA.tar.gz HEAD
git archive --format=tar.xz -o OTB-sources-$CI_COMMIT_SHORT_SHA.tar.xz HEAD
# Remove old source file
echo "Removing old sources"
ssh \
ssh ${server_name} \
rm ${jobs_directory}/OTB-sources-*.zip \
# Push new source file
echo "Pushing new sources"
scp OTB-sources-$CI_COMMIT_SHORT_SHA.* \${jobs_directory}/
echo ${CI_COMMIT_SHA} > ref.sha
echo "Pushing ref.sha"
scp ref.sha${jobs_directory}/
scp ref.sha ${server_name}:${jobs_directory}/
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment