[Asterisk-code-review] CI: Add wiki doc publish to periodics (asterisk[16])
George Joseph
asteriskteam at digium.com
Thu Jul 19 12:04:32 CDT 2018
George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/9529
Change subject: CI: Add wiki doc publish to periodics
......................................................................
CI: Add wiki doc publish to periodics
Change-Id: I29ba26134e5083bc6788ede235f1a5d4383c148a
---
M tests/CI/periodics-daily.jenkinsfile
A tests/CI/publishAsteriskDocs.sh
2 files changed, 166 insertions(+), 2 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/29/9529/1
diff --git a/tests/CI/periodics-daily.jenkinsfile b/tests/CI/periodics-daily.jenkinsfile
index 8f53658..7676931 100644
--- a/tests/CI/periodics-daily.jenkinsfile
+++ b/tests/CI/periodics-daily.jenkinsfile
@@ -43,8 +43,8 @@
def img = docker.image(randomImage)
img.pull()
- stage ("Build") {
- img.inside(dockerOptions + " --name ${bt}-build") {
+ img.inside(dockerOptions + " --name ${bt}-build") {
+ stage ("Build") {
echo 'Building..'
env.CCACHE_DIR = "/srv/cache/ccache"
sh "./tests/CI/buildAsterisk.sh --output-dir=${outputdir} --cache-dir=/srv/cache"
@@ -52,6 +52,28 @@
archiveArtifacts allowEmptyArchive: true, defaultExcludes: false, fingerprint: false,
artifacts: "${outputdir}/*"
}
+ stage ("Docs") {
+
+ sh 'sudo ./tests/CI/installAsterisk.sh --user-group=jenkins:users'
+
+ def docUrl = env.GIT_URL.replaceAll(/\/[^\/]+$/, "/publish-docs")
+ checkout scm: [$class: 'GitSCM',
+ branches: [[name: "master"]],
+ extensions: [
+ [$class: 'RelativeTargetDirectory', relativeTargetDir: "tests/CI/output/publish-docs"],
+ [$class: 'CloneOption',
+ noTags: true,
+ depth: 10,
+ honorRefspec: true,
+ shallow: true
+ ],
+ ],
+ userRemoteConfigs: [[url: docUrl]]
+ ]
+
+ sh './tests/CI/publishAsteriskDocs.sh --branch-name=${BRANCH_NAME}'
+ }
+
}
def testGroups = readJSON file: "tests/CI/periodic-dailyTestGroups.json"
diff --git a/tests/CI/publishAsteriskDocs.sh b/tests/CI/publishAsteriskDocs.sh
new file mode 100755
index 0000000..54c962a
--- /dev/null
+++ b/tests/CI/publishAsteriskDocs.sh
@@ -0,0 +1,142 @@
+#
+# Publish Asterisk documentation to the wiki
+#
+#!/usr/bin/env bash
+CIDIR=$(dirname $(readlink -fn $0))
+source $CIDIR/ci.functions
+ASTETCDIR=$DESTDIR/etc/asterisk
+
+ASTERISK="$DESTDIR/usr/sbin/asterisk"
+CONFFILE=$ASTETCDIR/asterisk.conf
+OUTPUTDIR=${OUTPUT_DIR:-tests/CI/output/publish-docs}
+
+[ ! -d ${OUTPUTDIR} ] && mkdir -p $OUTPUTDIR
+[ x"$USER_GROUP" != x ] && sudo chown -R $USER_GROUP $OUTPUTDIR
+
+rm -rf $ASTETCDIR/extensions.{ael,lua} || :
+
+if test -f ~/.asterisk-wiki.conf; then
+ . ~/.asterisk-wiki.conf
+fi
+
+: ${AWK:=awk}
+: ${GREP:=grep}
+: ${MAKE:=make}
+: ${GIT:=git}
+
+function fail()
+{
+ echo "${PROGNAME}: " "$@" >&2
+ exit 1
+}
+
+function usage()
+{
+ echo "usage: ${PROGNAME} --branch-name=<branch> [ --user-group=<user>:<group> ] [ --output-dir=<output_dir> ]"
+}
+
+#
+# Check settings from config file
+#
+if ! test ${CONFLUENCE_URL}; then
+ fail "CONFLUENCE_URL not set in ~/.asterisk-wiki.conf"
+fi
+
+if ! test ${CONFLUENCE_USER}; then
+ fail "CONFLUENCE_USER not set in ~/.asterisk-wiki.conf"
+fi
+
+if ! test ${CONFLUENCE_PASSWORD}; then
+ fail "CONFLUENCE_PASSWORD not set in ~/.asterisk-wiki.conf"
+fi
+# needed by publishing scripts. pass via the environment so it doesn't show
+# up in the logs.
+export CONFLUENCE_PASSWORD
+
+# default space to AST
+: ${CONFLUENCE_SPACE:=AST}
+
+#
+# Check repository
+#
+if ! test -f main/asterisk.c; then
+ fail "Must run from an Asterisk checkout"
+fi
+
+#
+# Check current working copy
+#
+CHANGES=$(${GIT} status | grep 'modified:' | wc -l)
+if test ${CHANGES} -ne 0; then
+ fail "Asterisk checkout must be clean"
+fi
+
+# Verbose, and exit on any command failure
+set -ex
+
+AST_VER=$(export GREP; export AWK; ./build_tools/make_version .)
+
+# Generate latest ARI documentation
+make ari-stubs
+
+# Ensure docs are consistent with the implementation
+CHANGES=$(${GIT} status | grep 'modified:' | wc -l)
+if test ${CHANGES} -ne 0; then
+ fail "Asterisk code out of date compared to the model"
+fi
+
+# make ari-stubs may modify the $Revision$ tags in a file; revert the
+# changes
+${GIT} reset --hard
+
+#
+# Don't publish docs for master. We still want the above validation to ensure
+# that REST API docs are kept up to date.
+#
+if test ${BRANCH_NAME} = 'master'; then
+ exit 0;
+fi
+
+#
+# Publish the REST API.
+#
+
+${OUTPUTDIR}/publish-rest-api.py --username="${CONFLUENCE_USER}" \
+ --verbose \
+ --ast-version="${AST_VER}" \
+ ${CONFLUENCE_URL} \
+ ${CONFLUENCE_SPACE} \
+ "Asterisk ${BRANCH_NAME}"
+
+rm -f ${OUTPUTDIR}/full-en_US.xml
+
+sudo $ASTERISK ${USER_GROUP:+-U ${USER_GROUP%%:*} -G ${USER_GROUP##*:}} -gn -C $CONFFILE
+for n in `seq 1 5` ; do
+ sleep 3
+ $ASTERISK -rx "core waitfullybooted" -C $CONFFILE && break
+done
+sleep 1
+$ASTERISK -rx "xmldoc dump ${OUTPUTDIR}/asterisk-docs.xml" -C $CONFFILE
+$ASTERISK -rx "core stop now" -C $CONFFILE
+
+#
+# Set the prefix argument for publishing docs
+#
+PREFIX="Asterisk ${BRANCH_NAME}"
+
+#
+# Publish XML documentation.
+#
+
+# Script assumes that it's running from TOPDIR
+pushd ${OUTPUTDIR}
+
+./astxml2wiki.py --username="${CONFLUENCE_USER}" \
+ --server=${CONFLUENCE_URL} \
+ --prefix="${PREFIX}" \
+ --space="${CONFLUENCE_SPACE}" \
+ --file=asterisk-docs.xml \
+ --ast-version="${AST_VER}" \
+ -v
+
+popd
\ No newline at end of file
--
To view, visit https://gerrit.asterisk.org/9529
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-MessageType: newchange
Gerrit-Change-Id: I29ba26134e5083bc6788ede235f1a5d4383c148a
Gerrit-Change-Number: 9529
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180719/c8039b49/attachment-0001.html>
More information about the asterisk-code-review
mailing list