Add a --dry-run flag to build that allows a Jenkins build without deploying anything.

Change-Id: I240da05118e86a85134bf2eb04ea6a617502e47c
diff --git a/tools/build/onos-build-and-upload b/tools/build/onos-build-and-upload
index bdf2f36..ba4441c 100755
--- a/tools/build/onos-build-and-upload
+++ b/tools/build/onos-build-and-upload
@@ -6,27 +6,35 @@
 VERSION=$1
 NEXT_VERSION=$2
 BRANCH=$3
+DRY_RUN=$4
+
+dryRun=0
+if [ "${DRY_RUN}" == "--dry-run" ]; then
+    dryRun=1
+fi
 
 set -e
 set -x
 
 # fix version strings, build artifacts, upload artifacts
-onos-release $VERSION | tee build.log
+onos-release $VERSION $DRY_RUN | tee build.log
 
-# upload docs
-onos-upload-docs ${WIKI_USER}
+if [ $dryRun -eq 0 ]; then
+    # upload docs
+    onos-upload-docs ${WIKI_USER}
 
-# upload release bits
-onos-upload-bits
+    # upload release bits
+    onos-upload-bits
 
-# spot check that uploaded artifacts are correct
-check-uploaded-maven-artifacts  $VERSION $ONOS_ROOT https://oss.sonatype.org/content/groups/staging
+    # spot check that uploaded artifacts are correct
+    check-uploaded-maven-artifacts  $VERSION $ONOS_ROOT https://oss.sonatype.org/content/groups/staging
 
-# set the version strings to the next version
-onos-snapshot ${NEXT_VERSION}
+    # set the version strings to the next version
+    onos-snapshot ${NEXT_VERSION}
 
-# Push version string changes to git
-git push origin ${BRANCH}
+    # Push version string changes to git
+    git push origin ${BRANCH}
 
-# Push tag for this build to git
-git push origin ${VERSION}
+    # Push tag for this build to git
+    git push origin ${VERSION}
+fi
diff --git a/tools/build/onos-build-release b/tools/build/onos-build-release
index ee39597..914b640 100755
--- a/tools/build/onos-build-release
+++ b/tools/build/onos-build-release
@@ -3,28 +3,43 @@
 # Builds an ONOS release
 # -----------------------------------------------------------------------------
 
-if [ $# -ne 3 ]; then
-    echo "Usage: onos-build-release version next-version branch"
+if [ $# -ne 3  -a $# -ne 4 ]; then
+    echo "Usage: onos-build-release version next-version branch [--dry-run]"
     echo "For example, to build rc2 on the 1.8 branch - onos-build-release onos-1.8 1.8.0-rc2 1.8.0-SNAPSHOT"
     exit 1
 fi
 
+if [ $# -eq 4 -a "${4}" != "--dry-run" ]; then
+    echo "$4 is an invalid parameter - only --dry-run allowed"
+    exit 1
+fi
+
 BRANCH=$1
 VERSION=$2
 NEXT_VERSION=$3
+DRY_RUN=$4
 
 set -e
 set -x
 
-# Check that environment setup is correct
-onos-release-prerequisites
+IS_DRY_RUN=0
+if [ "${DRY_RUN}" == "--dry-run" ]; then
+    IS_DRY_RUN=1
+fi
 
-# Block commits to Gerrit
-ssh -p 29418 gerrit.onosproject.org projectlock lock onos ${BRANCH}
+# Check that environment setup is correct
+onos-release-prerequisites ${DRY_RUN}
+
+if [ ${IS_DRY_RUN} -eq 0 ]; then
+    # Block commits to Gerrit
+    ssh -p 29418 gerrit.onosproject.org projectlock lock onos ${BRANCH}
+fi
 
 # Prepare the build tree
-onos-prepare-release $VERSION $BRANCH "onos-build-and-upload $VERSION $NEXT_VERSION $BRANCH"
+onos-prepare-release $VERSION $BRANCH "onos-build-and-upload $VERSION $NEXT_VERSION $BRANCH $DRY_RUN"
 
-# Unblock commits
-ssh -p 29418 gerrit.onosproject.org projectlock unlock onos ${BRANCH}
+if [ ${IS_DRY_RUN} -eq 0 ]; then
+    # Unblock commits
+    ssh -p 29418 gerrit.onosproject.org projectlock unlock onos ${BRANCH}
+fi
 
diff --git a/tools/build/onos-release b/tools/build/onos-release
index 901425c..d903b0b 100755
--- a/tools/build/onos-release
+++ b/tools/build/onos-release
@@ -9,6 +9,12 @@
 set -e
 
 export NEW_VERSION=${1:-$ONOS_VERSION}
+DRY_RUN=${2:-""}
+dryRun=0
+if [ "${DRY_RUN}" == "--dry-run" ]; then
+    dryRun=1
+fi
+
 [ -z "$NEW_VERSION" ] && echo "New ONOS version not specified" && exit 1
 
 export NEW_VERSION_SHORT=${NEW_VERSION%-SNAPSHOT}
@@ -27,7 +33,12 @@
 
 # Build ONOS & deploy to staging repo using the release profile.
 onos-buck build onos
-time onos-buck-publish
+
+if [ $dryRun -eq 0 ]; then
+    time onos-buck-publish
+else
+    time onos-buck-publish-local
+fi
 
 # Build ONOS docs
 onos-buck build //docs:internal //docs:external
diff --git a/tools/build/onos-release-prerequisites b/tools/build/onos-release-prerequisites
index fef52a4..1eb4cb9 100755
--- a/tools/build/onos-release-prerequisites
+++ b/tools/build/onos-release-prerequisites
@@ -5,6 +5,11 @@
 
 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
 
+dryRun=0
+if [ "${1}" == "--dry-run" ]; then
+    dryRun=1
+fi
+
 GERRIT_USER=${GERRIT_USER:-$USER}
 WIKI_USER=${WIKI_USER:-$USER}
 
@@ -180,9 +185,12 @@
 testToolchain
 testSnapshotDependencies
 testGerritAccess
-testWikiAccess
-testEC2Access
-testSonatypeAccessMvn
-testSonatypeAccessRest
+
+if [ ${dryRun} -eq 0 ]; then
+    testWikiAccess
+    testEC2Access
+    testSonatypeAccessMvn
+    testSonatypeAccessRest
+fi
 
 echo "Ready to commence release process!"
diff --git a/tools/build/onos-validate-change-version.excludes b/tools/build/onos-validate-change-version.excludes
index 0e56108..86c79e5 100755
--- a/tools/build/onos-validate-change-version.excludes
+++ b/tools/build/onos-validate-change-version.excludes
@@ -12,6 +12,7 @@
 \./tools/build/onos-validate-change-version
 \./tools/build/onos-change-version
 \./tools/build/onos-release
+\./tools/build/onos-build-release
 \./tools/build/onos-snapshot
 \./tools/package/archetypes/.*/archetype\.properties
 \./tools/package/maven-plugin/pom.xml