contrib/jenkins.sh: build and publish manuals

Add new environment variables WITH_MANUALS and PUBLISH to control if
the manuals should be built and uploaded. Describe all environment vars
on top of the file.

Related: OS#3385
Change-Id: I89be11d346d50169282c991235ffc47dacc30b11
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 5bab5bf..7083976 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -1,4 +1,13 @@
 #!/bin/sh -ex
+# jenkins build helper script for openbsc.  This is how we build on jenkins.osmocom.org
+#
+# environment variables:
+# * IU: configure 3G support (values: "--enable-iu", "--disable-iu")
+# * MGCP: configure transcoding for MGCP (values: "--enable-mgcp-transcoding", "--disable-mgcp-transcoding")
+# * SMPP: configure the SMPP interface (values: "--enable-smpp", "--disable-smpp")
+# * WITH_MANUALS: build manual PDFs if set to "1"
+# * PUBLISH: upload manuals after building if set to "1" (ignored without WITH_MANUALS = "1")
+#
 
 osmo-clean-workspace.sh
 
@@ -59,4 +68,24 @@
 
 . osmo-build.sh
 
+# Build and publish manuals
+if [ "$WITH_MANUALS" = "1" ]; then
+	# Build all manuals first
+	osmo-build-dep.sh osmo-gsm-manuals
+	for dir in "$base"/manuals/*/; do
+		make -C "$dir"
+	done
+
+	# Run 'make check' for the OsmoNITB manuals.
+	# The other dirs only have VTY references, so there is no 'make check' target for them.
+	make -C "$base/manuals/OsmoNITB" check
+
+	# Publish all at once
+	if [ "$PUBLISH" = "1" ]; then
+		for dir in "$base"/manuals/*/; do
+			make -C "$dir" publish
+		done
+	fi
+fi
+
 osmo-clean-workspace.sh