Release build job is now functional

- add Jenkins user ssh key
- add Jenkins user gpg key
- lock/unlock gerrit
- set proper git identity

Change-Id: I3f89598e46f9a32598ac5840a122a16f983d873a
diff --git a/jjb/onos/onos-release-build.sh b/jjb/onos/onos-release-build.sh
index 0b2bf46..68363b5 100644
--- a/jjb/onos/onos-release-build.sh
+++ b/jjb/onos/onos-release-build.sh
@@ -1,32 +1,48 @@
 #!/bin/bash -ex
 
+# exit on errors
+set -eu -o pipefail
+
 # set up ONOS build environment
 ONOS_ROOT=`pwd`
 . tools/build/envDefaults
 
 # import GPG key
 gpg --import jenkins.key
-
-env
  
 # set up release build credentials
 . onos-build-credentials
 
-env
-
-git config user.email "jenkins@onosproject.org"
+# configure git settings
+git config user.email "jenkins@onlab.us"
 git config user.name "ONOS Jenkins User"
 
+# install boto
+pip install -U boto
+
 # stage the maven settings
 mkdir -p ~/.m2
 mv settings.xml ~/.m2/settings.xml
 
-# stage the SSH key
-cp id_rsa.pub ~/.ssh
+# stage and add the build SSH key
+chmod 600 id_rsa.pub
+ssh-add id_rsa.pub
+
+# Add the javadoc server to the list of known hosts
+ssh-keyscan -H -t rsa api.onosproject.org >>~/.ssh/known_hosts
 
 # set user to use for uploading javadocs
 WIKI_USER="jenkins"
 export WIKI_USER
 
+# lock gerrit to prevent checkins
+ssh -p 29418 gerrit.onosproject.org projectlock lock onos master
+
+# unlock on exit
+trap "ssh -p 29418 gerrit.onosproject.org projectlock unlock onos master" EXIT
+
+# get the sources
+git checkout $GERRIT_BRANCH
+
 # run the build
 onos-build-and-upload ${ONOS_VERSION} ${ONOS_NEXT_VERSION} ${GERRIT_BRANCH}