ci: Embedding CI build and test running script

This commit also unifies build and test scripts for Jenkins and Travis CI

Change-Id: I6ee99c51032769629eb2c62b40608033fa9cac78
diff --git a/.jenkins.d/10-build.sh b/.jenkins.d/10-build.sh
new file mode 100755
index 0000000..e8811bd
--- /dev/null
+++ b/.jenkins.d/10-build.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+set -x
+
+# Cleanup
+sudo ./waf distclean -j1 --color=yes
+
+COVERAGE=$( python -c "print '--with-coverage' if 'code-coverage' in '$JOB_NAME' else ''" )
+
+sudo rm -Rf /usr/local/include/ndn-cxx
+sudo rm -f /usr/local/lib/libndn-cxx*
+sudo rm -f /usr/local/lib/pkgconfig/libndn-cxx*
+
+# Configure
+CXXFLAGS="-std=c++03 -pedantic -Wall -Wno-long-long -O2 -g -Werror" \
+  ./waf -j1 configure --color=yes --with-tests --without-pch $COVERAGE
+
+# Build
+./waf --color=yes -j1
+
+# Install
+sudo ./waf -j1 --color=yes install
+sudo ldconfig || true
diff --git a/.jenkins.d/20-tests.sh b/.jenkins.d/20-tests.sh
new file mode 100755
index 0000000..ab404ae
--- /dev/null
+++ b/.jenkins.d/20-tests.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+set -x
+
+# Prepare environment
+rm -Rf ~/.ndnx ~/.ndn
+
+echo $NODE_LABELS
+IS_OSX=$( python -c "print 'yes' if 'OSX' in '$NODE_LABELS'.strip().split(' ') else 'no'" )
+
+if [[ $IS_OSX == "yes" ]]; then
+  echo "Unlocking OSX Keychain"
+  security unlock-keychain -p "named-data"
+fi
+
+ndnsec-keygen "/tmp/jenkins/$NODE_NAME" | ndnsec-install-cert -
+
+# Run unit tests
+./build/unit-tests -l test_suite
diff --git a/.jenkins.d/30-coverage.sh b/.jenkins.d/30-coverage.sh
new file mode 100755
index 0000000..7b8f1af
--- /dev/null
+++ b/.jenkins.d/30-coverage.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+set -x
+
+IS_COVR=$( python -c "print 'yes' if 'code-coverage' in '$JOB_NAME' else 'no'" )
+
+if [[ $IS_COVR == "yes" ]]; then
+  BASE="`pwd | sed -e 's|/|\\\/|g'`\\"
+  (cd build && gcovr -x -f $BASE/src -r ../ -o coverage.xml -b ./)
+fi