Skip to content
Snippets Groups Projects
Commit 8e8d6586 authored by Amin Bandali's avatar Amin Bandali
Browse files

misc: add Jenkins pipeline for build validation and deployment

* _build/Dockerfile.build: New Dockerfile for docs-build pipeline,
with the required tools for building the docs installed.
* _build/Jenkinsfile.build: New Jenkinsfile defining the docs-build
pipeline.

Change-Id: If50e687a5b9342eb2dcb5cb39e8a63db91f8616d
parent bbf7fb90
No related branches found
No related tags found
No related merge requests found
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
// 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' }
}
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment