[Asterisk-code-review] CI: Add wiki doc publish to periodics (asterisk[16])
Jenkins2
asteriskteam at digium.com
Mon Jul 23 06:46:54 CDT 2018
Jenkins2 has submitted this change and it was merged. ( 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, 170 insertions(+), 5 deletions(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, but someone else must approve
Jenkins2: Looks good to me, approved; Approved for Submit
diff --git a/tests/CI/periodics-daily.jenkinsfile b/tests/CI/periodics-daily.jenkinsfile
index 8f53658..335edd9 100644
--- a/tests/CI/periodics-daily.jenkinsfile
+++ b/tests/CI/periodics-daily.jenkinsfile
@@ -14,7 +14,7 @@
triggers {
cron 'H H(0-4) * * *'
}
-
+
agent {
/* All of the stages need to be performed on a docker host */
label "swdev-docker"
@@ -26,7 +26,7 @@
/* Here's where we switch to scripted pipeline */
script {
stage ("Checkout") {
- sh "sudo chown -R jenkins:users ."
+ sh "sudo chown -R jenkins:users ."
sh "printenv | sort"
sh "sudo tests/CI/setupJenkinsEnvironment.sh"
}
@@ -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,27 @@
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} --wiki-doc-branch-regex=\"${WIKI_DOC_BRANCH_REGEX}\""
+ }
}
def testGroups = readJSON file: "tests/CI/periodic-dailyTestGroups.json"
@@ -78,7 +99,7 @@
}
sh "sudo rm -rf ${groupDir} || : "
-
+
checkout scm: [$class: 'GitSCM',
branches: [[name: "${BRANCH_NAME}"]],
extensions: [
diff --git a/tests/CI/publishAsteriskDocs.sh b/tests/CI/publishAsteriskDocs.sh
new file mode 100755
index 0000000..d5c857a
--- /dev/null
+++ b/tests/CI/publishAsteriskDocs.sh
@@ -0,0 +1,144 @@
+#
+# 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 non-main-release branches. We still want the above
+# validation to ensure that REST API docs are kept up to date though.
+#
+if [ -n "$WIKI_DOC_BRANCH_REGEX" ] ; then
+ if [[ ! ${BRANCH_NAME} =~ $WIKI_DOC_BRANCH_REGEX ]] ; then
+ exit 0;
+ fi
+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: merged
Gerrit-Change-Id: I29ba26134e5083bc6788ede235f1a5d4383c148a
Gerrit-Change-Number: 9529
Gerrit-PatchSet: 3
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180723/4c8d22ca/attachment-0001.html>
More information about the asterisk-code-review
mailing list