diff --git a/_build/Dockerfile.build b/_build/Dockerfile.build new file mode 100644 index 0000000000000000000000000000000000000000..b2ad19df18ca38f1dcfe592de1e5897b9d526887 --- /dev/null +++ b/_build/Dockerfile.build @@ -0,0 +1,22 @@ +FROM debian:bullseye-slim + +ARG UID=1000 +ARG GID=1000 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get clean +RUN apt-get update && \ + apt-get install -y -o Acquire::Retries=10 \ + curl \ + make \ + python3-pip + +RUN groupadd -g "${GID}" jenkins && \ + useradd --create-home --no-log-init -u "${UID}" -g "${GID}" jenkins + +USER jenkins + +ENV PATH="/home/jenkins/.local/bin:${PATH}" + +RUN pip3 install Sphinx sphinx-intl sphinx-rtd-theme myst-parser diff --git a/_build/Jenkinsfile.build b/_build/Jenkinsfile.build new file mode 100644 index 0000000000000000000000000000000000000000..8868c0f29de3494618ea312df964259c21fe528c --- /dev/null +++ b/_build/Jenkinsfile.build @@ -0,0 +1,108 @@ +// Copyright (C) 2022 Savoir-faire Linux Inc. +// +// Author: Amin Bandali <amin.bandali@savoirfairelinux.com> +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +// Build (both validation and deployment) of jami-docs. + +// Configuration globals. +def REPO_NAME = 'jami-docs' +def DL_SSH_KEY = '5825b39b-dfc6-435f-918e-12acc1f56221' +def REMOTE_HOST = env.SSH_HOST_DL_RING_CX +def REMOTE_BASE_DIR = '/srv/repository/ring/docs' +def DOCKER_IMAGE = "docs-build:${BUILD_ID}" +def DOCKER_FILE = '_build/Dockerfile.build' + +pipeline { + agent { + label 'linux-builder' + } + + triggers { + gerrit customUrl: '', + gerritProjects: [ + [branches: [[compareType: 'PLAIN', pattern: 'master']], + compareType: 'PLAIN', + disableStrictForbiddenFileVerification: false, + pattern: REPO_NAME]], + triggerOnEvents: [ + commentAddedContains('!build'), + patchsetCreated(excludeDrafts: true, + excludeNoCodeChange: true, + excludeTrivialRebase: true), + changeMerged()] + } + + options { + ansiColor('xterm') + } + + parameters { + string(name: 'GERRIT_REFSPEC', + defaultValue: 'refs/heads/master', + description: 'The Gerrit refspec to fetch.') + } + + stages { + stage('Build docs-build docker image') { + steps { + script { + def jenkinsUID = sh(returnStdout: true, script: 'id -u jenkins').replaceAll("\n", '').trim() + def jenkinsGID = sh(returnStdout: true, script: 'id -g jenkins').replaceAll("\n", '').trim() + def docker_args = + ["--build-arg UID=${jenkinsUID}", + "--build-arg GID=${jenkinsGID}", + "-f ${DOCKER_FILE} ."].join(' ') + docker.build(DOCKER_IMAGE, docker_args) + } + } + } + + stage('Run docs-build docker image') { + steps { + script { + def pwd = pwd() + def docker_args = "-t -v ${pwd}:/${REPO_NAME}:rw -e BATCH_MODE=1" + docker.image(DOCKER_IMAGE).withRun(docker_args) { container -> + def run_cmd = { cmd -> + sh "set +x; docker exec -t ${container.id} /bin/sh -c '${cmd}'" + } + stage('Build docs') { + run_cmd(""" + cd ${REPO_NAME} + make html + """) + } + } + } + } + } + + stage('Deploy docs') { + when { + environment name: 'GERRIT_EVENT_TYPE', + value: 'change-merged' + } + environment { + RSYNC_DEST = "${REMOTE_HOST}:${REMOTE_BASE_DIR}" + } + steps { + sshagent(credentials: [DL_SSH_KEY]) { + script { sh 'make deploy' } + } + } + } + } +}