bot-base/Jenkinsfile

86 lines
2.5 KiB
Plaintext
Raw Normal View History

2020-04-25 16:56:52 +02:00
pipeline {
2020-04-26 13:54:37 +02:00
agent {
dockerfile {
2020-04-26 18:33:19 +02:00
args '-u root -v $HOME/docker_volumes/.cache/:/root/.cache/'
2020-04-26 13:54:37 +02:00
}
}
environment {
SPHINXOPTS = '-w sphinx-build.log'
DEPLOY_HOST = 'docs@172.17.0.1'
2020-04-26 14:58:29 +02:00
DEPLOY_PATH = 'www/docs/bot-base/'
2020-04-26 13:54:37 +02:00
}
2020-04-25 16:56:52 +02:00
stages {
2020-04-26 13:54:37 +02:00
stage('Install Dependencies') {
steps {
sh 'pipenv sync --sequential --dev'
2020-04-25 16:56:52 +02:00
}
2020-04-26 13:54:37 +02:00
}
stage('Run Tests') {
2020-04-25 16:56:52 +02:00
steps {
2020-04-26 13:54:37 +02:00
sh '''export PYTHONPATH=$(pwd)/python
cd src
pipenv run pytest -p no:warnings --junit-xml test-reports/results.xml'''
2020-04-25 16:56:52 +02:00
}
post {
always {
2020-04-26 00:01:34 +02:00
junit 'src/test-reports/results.xml'
2020-04-25 16:56:52 +02:00
}
}
}
2020-04-26 13:54:37 +02:00
stage('Build Documentation') {
steps {
sh '''export PYTHONPATH=$(pwd)/python
cd doc
rm -f sphinx-build.log
pipenv run make html'''
}
post {
failure {
sh 'cat doc/sphinx-build.log'
}
}
}
stage('Deploy Documentation') {
2020-04-26 21:02:47 +02:00
when {
anyOf {
branch 'stable'
branch 'unstable'
2020-04-26 21:09:55 +02:00
buildingTag()
2020-04-26 21:02:47 +02:00
}
}
2020-04-26 13:54:37 +02:00
steps {
2020-04-26 21:19:32 +02:00
script {
2020-04-26 21:14:10 +02:00
echo "Hello world"
def SUB_PATH = """${sh(
returnStdout: true,
script: 'echo "${GIT_BRANCH#*/}"'
)}""".trim()
if (buildingTag()) {
SUB_PATH="${env.TAG_NAME}"
}
2020-04-26 21:19:32 +02:00
}
sshagent(credentials: ['1cf72f47-b70c-4f90-a958-020956099d19']) {
withEnv(["SUB_PATH=${SUB_PATH}"]) {
sh '''cd doc
rm -f rsync.log
ssh -o StrictHostKeyChecking=no -o BatchMode=yes ${DEPLOY_HOST} mkdir -p ${DEPLOY_PATH}${SUB_PATH}/
rsync -aze 'ssh -o StrictHostKeyChecking=no -o BatchMode=yes' \
--log-file=rsync.log \
--delete \
./build/html/ ${DEPLOY_HOST}:${DEPLOY_PATH}${SUB_PATH}/'''
2020-04-26 21:02:47 +02:00
}
2020-04-26 13:54:37 +02:00
}
}
post {
failure {
sh 'cat doc/rsync.log'
}
}
}
2020-04-25 16:56:52 +02:00
}
}