summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorm00133142 <meimei@huawei.com>2015-04-20 11:04:56 +0800
committerm00133142 <meimei@huawei.com>2015-04-27 15:43:39 +0800
commitcafeb3a2ef6f894cb14632917f29d795b5aeba74 (patch)
tree4010ffa030feda03a46a1e8bc79fecc2ac015a1a
parentd4cf08d6293091f6dd763dc6e8dcbdaf1d1c800a (diff)
Add script of launch slave to OPNFV Jenkins by using JNLP
JIRA: OCTO-51 Change-Id: Ib4293a15c409f2d9f8a4671094029ba57cdb1cb3 Signed-off-by: m00133142 <meimei@huawei.com>
-rwxr-xr-xci/README13
-rwxr-xr-xci/jenkins-slave.init37
2 files changed, 34 insertions, 16 deletions
diff --git a/ci/README b/ci/README
index a830076..d1bb1b1 100755
--- a/ci/README
+++ b/ci/README
@@ -9,16 +9,17 @@
Before use this script please make sure things below you have done:
1.Install JDK on server
2.Create local user on server: jenkins
-3.Create the local workspace configured in jenkins
-3.Download slave.jar and put it into $HOME directory of jenkins user
-4.Your slave has been configured in OPNFV Jenkins
-5.Obtain slave's token from Linux Foundation Helpdesk
+3.Your slave has been configured in OPNFV Jenkins master
+4.Create slave's local workspace that has been configured in jenkins master
+5.Download slave.jar and put it into the folder of /home/jenkins/
+6.Obtain slave's token from Linux Foundation Helpdesk
Consult wiki : https://wiki.opnfv.org/wiki/jenkins#how_to_connect_servers_from_labs_to_opnfv_jenkins
Follow steps below to launch your slave to OPNFV Jenkins:
1. cp jenkins-slave.init /etc/init.d/jenkins-slave
2. chmod +x /etc/init.d/jenkins-slave
-3. define $SLAVENAME&$TOKEN in config file(jenkins-slave)
+3. Define $SLAVENAME&$TOKEN in config file(jenkins-slave)
4. cp jenkins-slave /etc/default/jenkins-slave
5. service jenkins-slave start
-Finally, run "service jenkins-slave status" command to check the process is running, see the log(/home/jenkins/slave.log) to confirm the connect to OPNFV Jenkins. \ No newline at end of file
+
+Finally, run "service jenkins-slave status" command to check the process is running, see the log(/home/jenkins/jenkins-slave/slave.log) to confirm the connection to OPNFV Jenkins.
diff --git a/ci/jenkins-slave.init b/ci/jenkins-slave.init
index 8402b67..35dc2fd 100755
--- a/ci/jenkins-slave.init
+++ b/ci/jenkins-slave.init
@@ -12,27 +12,44 @@ set -o nounset
set -o pipefail
SLAVE_CONF="/etc/default/jenkins-slave"
-if [ -f ${SLAVE_CONF} ]; then
+
+if [ -f ${SLAVE_CONF} ]
+then
. ${SLAVE_CONF}
else
- echo "Fatal : Configuration file dosenot exist, details please refer to README."
+ echo "Error : Configuration file ($SLAVE_CONF) does not exist, details please refer to README."
exit
fi
if [ -z "${SLAVENAME}" ] || [ -z "${TOKEN}" ]
then
- echo "Fatal : Lack of slavename and token"
+ echo "Error : Please define SLAVENAME and TOKEN values in the Configuration file ($SLAVE_CONF), details please refer to README."
exit
fi
+SLAVE_JNLP="-jnlpUrl https://build.opnfv.org/ci/computer/${SLAVENAME}/slave-agent.jnlp"
JENKINS_HOME="/home/jenkins"
-PID_FILE="${JENKINS_HOME}/slave.pid"
SLAVE_JAR="${JENKINS_HOME}/slave.jar"
-SLAVE_JNLP="-jnlpUrl https://build.opnfv.org/ci/computer/${SLAVENAME}/slave-agent.jnlp"
+JENKINS_SLAVE_ROOTDIR="${JENKINS_HOME}/jenkins-slave"
+PID_FILE="${JENKINS_SLAVE_ROOTDIR}/slave.pid"
+SLAVE_LOG="${JENKINS_SLAVE_ROOTDIR}/slave.log"
USER="jenkins"
-SLAVE_LOG="${JENKINS_HOME}/slave.log"
+GROUP="jenkins"
JAVA_BIN="/usr/bin/java"
+if [ ! -f ${SLAVE_JAR} ]
+then
+ echo "Error : ${SLAVE_JAR} dosenot exist, details please refer to README."
+ exit
+fi
+
+[ -e ${JENKINS_SLAVE_ROOTDIR} ] || { mkdir ${JENKINS_SLAVE_ROOTDIR}; chown ${USER}:${GROUP} ${JENKINS_SLAVE_ROOTDIR};};
+if [ ! -d ${JENKINS_SLAVE_ROOTDIR} ]
+then
+ echo "Error : ${JENKINS_SLAVE_ROOTDIR} can not be created! Maybe there is a file with the same name of 'jenkins-slave'."
+ exit
+fi
+
usage ()
{
cat<<EOF
@@ -74,7 +91,7 @@ status()
then
echo "jenkins slave is not running!"
else
- echo "jenkins slave is running, pid is $pid"
+ echo "jenkins slave is running, pid is $pid"
fi
}
@@ -82,7 +99,7 @@ if [ $# -gt 0 ]
then
OPTION=$1
else
- echo "None valid argument!"
+ echo "Please input your argument!"
usage
exit 1
fi
@@ -103,8 +120,8 @@ case "$OPTION" in
status
;;
*)
- echo "$OPTION is not a valid argument!"
- usage
+ echo "Error: $OPTION is not a valid argument"
+ usage
exit 1
;;
esac