Bug 547225 - [Releng] Update publish script

- modify the publish script to use ssh connection to respect the new Eclipse Instance policies
- test the new gerrit job

Change-Id: I76105ccd0cf420d039fa5a646c1f6a57bac3705a
Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
diff --git a/org.eclipse.xwt.releng/promote-xwt.sh b/org.eclipse.xwt.releng/promote-xwt.sh
index 7ba269d..c36c45d 100755
--- a/org.eclipse.xwt.releng/promote-xwt.sh
+++ b/org.eclipse.xwt.releng/promote-xwt.sh
@@ -1,11 +1,17 @@
-#!/bin/bash -x
+#!/bin/bash
+########### Requirements ###########
+#You will need to have the 'ssh agent' plugin installed on your instance and configure the credentials for ssh access
+#You can find the needed informations here: https://wiki.eclipse.org/Jenkins#How_do_I_deploy_artifacts_to_download.eclipse.org.3F
+####################################
+sshGenie="genie.shared"
+sshRemote="projects-storage.eclipse.org"
 
+
+########### Parameters Initialization ###########
 #The specific localization
 remoteRoot="/home/data/httpd/download.eclipse.org"
 xwtRoot="xwt"
 
-
-########### Parameters Initialization ###########
 if [[ "$MILESTONE" == "-R" ]] ; then
   destination=$remoteRoot/$xwtRoot/release-$RELEASE_NUMBER
   destinationUpdateSite=$destination
@@ -13,24 +19,25 @@
   destination=$remoteRoot/$xwtRoot/milestones-$RELEASE_NUMBER
   destinationUpdateSite=$destination/$RELEASE_NUMBER$MILESTONE
 fi
-#echo $destinationUpdateSite
+echo $destinationUpdateSite
 
 jobArtifacts=$HOME/.jenkins/jobs/$PROMOTED_JOB_NAME/builds/$PROMOTED_NUMBER/archive
-#echo $jobArtifacts
-#ls $jobArtifacts
+echo $jobArtifacts
+ls $jobArtifacts
 
 if $SIGN ; then
   :
 else
   echo "The sources may not have been signed. Please verify the build and artifacts parameters and try again."
-  exit 1
+  exit 
 fi
 
 if [ -d $destination ] ; then
   if [ -d $destinationUpdateSite ] ; then
     if $OVERRIDE ; then
       echo "Removing previous artifacts"
-      rm -rf $destinationUpdateSite
+      exit 1 #remove this when authorizing overrides
+#      ssh $sshGenie@$sshRemote rm -rf $destinationUpdateSite
     else
       echo "The milestone already exists. You might want to change the suffix or delete the previous one."
       exit 1
@@ -43,12 +50,13 @@
 #Go to the artifact directory
 cd $jobArtifacts
 echo "Promoting the Job to $destinationUpdateSite"
+
 #No error if exists, makes parent directories as needed
-mkdir -p $destinationUpdateSite
+ssh $sshGenie@$sshRemote mkdir -p $destinationUpdateSite
 
 #Copy the contents onto the server folder
-cp -a *.zip $destinationUpdateSite
-cp -a repository/* $destinationUpdateSite
+scp *.zip $sshGenie@$sshRemote:$destinationUpdateSite
+scp -r repository/* $sshGenie@$sshRemote:$destinationUpdateSite
 
 
 ########### Create Index File ###########
@@ -78,7 +86,7 @@
 </p>
 </body>
 </html>
-' > $1/index.html
+' | ssh $sshGenie@$sshRemote -T "cat > $1/index.html"
 }
 echo "Create index.html file for the new repository"
 cerateIndexFile $destinationUpdateSite
@@ -87,11 +95,13 @@
 ########### Set Access Rights ###########
 # This function sets the acess rights to allow all memebers of the group to edit the files
 function setAccessRights() {
-	chmod -R 775 "$1"
-	chgrp -hR technology.xwt "$1"
+	ssh $sshGenie@$sshRemote chmod -R 775 "$1"
+	ssh $sshGenie@$sshRemote chgrp -hR technology.xwt "$1"
 }
 echo "Set access right -R: $destinationUpdateSite"
 setAccessRights $destinationUpdateSite
 
 
 echo "publishing done."
+
+