ESBO-ETC/Jenkinsfile

81 lines
2.5 KiB
Plaintext
Raw Normal View History

2020-07-21 11:22:31 +02:00
pipeline {
2020-07-21 14:01:51 +02:00
agent none
2020-07-21 11:22:31 +02:00
environment {
TEST_DIR = 'tests'
2020-07-21 11:22:31 +02:00
SPHINX_DIR = 'docs'
2020-07-21 13:41:21 +02:00
BUILD_DIR = 'build/html'
SOURCE_DIR = 'source'
2020-07-21 11:22:31 +02:00
}
stages {
2020-07-21 15:18:34 +02:00
stage('Test') {
agent {
2020-07-21 15:19:21 +02:00
dockerfile {
filename "Dockerfile"
2020-08-17 15:03:48 +02:00
args "--network=host"
2020-08-17 15:22:08 +02:00
additionalBuildArgs "--network=host"
2020-07-21 15:19:21 +02:00
}
2020-07-21 15:18:34 +02:00
}
steps {
// Install dependencies
sh '''
2020-07-22 08:13:28 +02:00
virtualenv venv
. venv/bin/activate
2020-07-21 15:18:34 +02:00
pip3 install -r requirements.txt
'''
2020-07-22 08:13:28 +02:00
// run tests
2020-07-21 15:42:16 +02:00
sh '''
export PYTHONPATH=`pwd`
2020-07-22 08:13:28 +02:00
venv/bin/python3 -m unittest discover ${TEST_DIR}
2020-07-21 15:42:16 +02:00
'''
2020-07-21 15:18:34 +02:00
}
}
stage('Build Docs') {
2020-07-21 14:01:51 +02:00
agent {
dockerfile {
filename "Dockerfile"
2020-08-17 15:03:48 +02:00
args "--network=host"
2020-08-17 15:22:08 +02:00
additionalBuildArgs "--network=host"
2020-07-21 14:01:51 +02:00
}
}
2020-07-21 11:22:31 +02:00
steps {
2020-07-21 14:01:51 +02:00
// Install dependencies
2020-07-21 11:22:31 +02:00
sh '''
2020-07-22 08:13:28 +02:00
virtualenv venv
. venv/bin/activate
2020-07-21 13:34:07 +02:00
pip3 install -r requirements.txt
2020-07-21 11:22:31 +02:00
'''
// clear out old files
sh 'rm -rf ${BUILD_DIR}'
sh 'rm -f ${SPHINX_DIR}/sphinx-build.log'
2020-07-22 08:13:28 +02:00
// build docs
2020-07-21 11:22:31 +02:00
sh '''
2020-09-09 17:20:05 +02:00
venv/bin/sphinx-apidoc -f -o docs/source/api esbo_etc
2020-07-22 08:13:28 +02:00
venv/bin/sphinx-build \
2020-07-21 13:56:58 +02:00
-w ${SPHINX_DIR}/sphinx-build.log \
-b html ${SPHINX_DIR}/${SOURCE_DIR} ${SPHINX_DIR}/${BUILD_DIR}
2020-07-21 11:22:31 +02:00
'''
2020-07-22 08:13:28 +02:00
// stash build result
2020-07-21 13:56:58 +02:00
stash includes: 'docs/build/html/**/*.*', name: 'html'
2020-07-21 11:22:31 +02:00
}
post {
failure {
sh 'cat ${SPHINX_DIR}/sphinx-build.log'
}
}
}
2020-07-22 08:13:28 +02:00
stage('Deploy Docs') {
2020-08-17 16:55:01 +02:00
agent {
label 'esbods'
}
steps {
// unstash build results from previous stage
unstash 'html'
// remove old files
sh 'rm -rf /var/www/html/esboetcdocs/*'
// copy new files
2020-08-17 16:57:23 +02:00
sh 'cp -rf docs/build/html/* /var/www/html/esboetcdocs/'
2020-08-17 16:55:01 +02:00
}
}
2020-08-17 17:01:50 +02:00
}
2020-07-21 11:22:31 +02:00
}