- Update publish script (no more direct access to workspace)


Change-Id: I77e8df126635807ded023aee8ed6f520c65ad020
diff --git a/compare/releng/scripts/publish-nightly.sh b/compare/releng/scripts/publish-nightly.sh
index 7303cf7..d14c562 100755
--- a/compare/releng/scripts/publish-nightly.sh
+++ b/compare/releng/scripts/publish-nightly.sh
@@ -23,7 +23,7 @@
 # The type of build being published
 BUILD_TYPE=nightly
 PROG=`basename $0`
-REPOSITORY_PATH="plugins/compare/org.eclipse.papyrus.compare.p2/target/repository"
+REPOSITORY_PATH="lastSuccessfulBuild/artifact"
 HELP=false
 
 ######################################################################
@@ -31,21 +31,22 @@
 ######################################################################
 
 usage() {
-  echo "Usage: "$PROG" [-h] -v version -i build-id -w workspace -r repository"
+  echo "Usage: "$PROG" [-h] -v version -j job -i build-id -r repository -z zip-name -b build-type"
   echo "  Options:"
   echo "    -v, --version     The version to be published. Format is X.Y.Z where X, Y and Z are integer"
-  echo "    -b, --build-type  The build type, one of n[ightly] (default), i[ntegration], or r[elease]"
+  echo "    -j, --job  		  The name of the job (Papyrus_Compare_Integration or Papyrus_Compare_Nightly)"
   echo "    -i, --build-id    The build ID. Format is YYYY-MM-DD_HH-MM-SS"
-  echo "    -w, --workspace   The folder where the artifacts have been built"
   echo "    -r, --repository  The repository folder to publish"
+  echo "    -z, --zip-name	  The name of the zip to download"
+  echo "    -b, --build-type  The kind of build (nightly, integration, release)"
   echo "    -h, --help        Display this help message"
 }
 
-SHORT_OPT_STRING="hw:b:i:v:r:"
+SHORT_OPT_STRING="h:j:i:r:z:b:v"
 getopt -T > /dev/null
 if [ $? -eq 4 ]; then
   # GNU enhanced getopt is available
-  ARGS=`getopt --name "$PROG" --long help,workspace:,build-type:,build-id:,version:,repository: --options "$SHORT_OPT_STRING" -- "$@"`
+  ARGS=`getopt --name "$PROG" --long help,zip-name:,build-type:,build-id:,version:,repository:,job --options "$SHORT_OPT_STRING" -- "$@"`
 else
   # Original getopt is available (no long option names, no whitespace, no sorting)
   ARGS=`getopt "$SHORT_OPT_STRING" "$@"`
@@ -59,11 +60,12 @@
 while [ $# -gt 0 ]; do
     case "$1" in
         -h | --help)        HELP=true;;
-        -w | --workspace)   WORKSPACE="$2"; shift;;
+        -j | --job)   		JOB_NAME="$2"; shift;;
         -b | --build-type)  BUILD_TYPE="$2"; shift;;
         -i | --build-id)    BUILD_ID="$2"; shift;;
         -v | --version)     VERSION="$2"; shift;;
         -r | --repository)  REPOSITORY_PATH="$2"; shift;;
+        -z | --zip-name)	ZIP_NAME="$2"; shift;;
         --)                 shift; break;; # end of options
     esac
     shift
@@ -74,14 +76,8 @@
   exit 0
 fi
 
-if [ -z "$WORKSPACE" ]; then
-  echo "$0: workspace argument is mandatory" >&2
-  usage >&2 
-  exit 1
-fi
-
-if [ ! -d "$WORKSPACE" ]; then
-  echo "$0: workspace does not exist or is not a directory -- $WORKSPACE" >&2
+if [ -z "$JOB_NAME" ]; then
+  echo "$0: job name argument is mandatory" >&2
   usage >&2 
   exit 1
 fi
@@ -92,12 +88,6 @@
   exit 1
 fi
 
-if [ ! -d "$REPOSITORY_PATH" ]; then
-  echo "$0: repository does not exist or is not a directory -- $REPOSITORY_PATH" >&2
-  usage >&2 
-  exit 1
-fi
-
 if [ -z "$BUILD_TYPE" ]; then
   BUILD_TYPE=nightly
   BUILD_PREFIX=$NIGHTLY_PREFIX
@@ -241,9 +231,15 @@
 # Ensure the target folder exists
 mkdir -p "$BUILD_PATH/$FULL_VERSION"
 # The actual publication of the p2 repo produced by the build
-cp -a "$WORKSPACE/$REPOSITORY_PATH/"* "$BUILD_PATH/$FULL_VERSION"
+mkdir "tmp"
+cd tmp
+wget --no-check-certificate "https://ci.eclipse.org/papyrus/job/${JOB_NAME}/${REPOSITORY_PATH}/${ZIP_NAME}"
+unzip -t ${ZIP_NAME}
+cp -a * "$BUILD_PATH/$FULL_VERSION"
 # Also publish a dump of the build environment, may be useful to debug
 env | sort > "$BUILD_PATH/$FULL_VERSION/build_env.txt"
+cd ..
+rm -r tmp
 
 echo "Adding $UPDATE_SITE_URL to composites repositories:"