132 lines
4.5 KiB
Groovy
132 lines
4.5 KiB
Groovy
def projectRoot = '/home/gerby/gerby'
|
|
|
|
def vGPython = "${projectRoot}/gerby-venv/bin/python"
|
|
def vGPip = "${projectRoot}/gerby-venv/bin/pip"
|
|
|
|
def vPPython = "${projectRoot}/plastex-venv/bin/python"
|
|
def vPPip = "${projectRoot}/plastex-venv/bin/pip"
|
|
|
|
def vPlastex = "${projectRoot}/plastex-venv/bin/plastex"
|
|
|
|
def discordHook = "https://discord.com/api/webhooks/1456391390513856676/yniOv0Gbxp2UwW1pbZcekpXsC8y1dYppGQ90O7He-df24IODggrgXdMFwvz-RMWM15j8"
|
|
|
|
pipeline {
|
|
agent any
|
|
|
|
stages {
|
|
stage('Create Links') {
|
|
steps {
|
|
dir("${projectRoot}/gerby-website/gerby/tools/") {
|
|
sh 'rm ./document || true'
|
|
sh 'rm ./document.paux || true'
|
|
sh 'rm ./tags || true'
|
|
sh 'ln -s ../../../document document'
|
|
sh 'ln -s ../../../document.paux document.paux'
|
|
sh 'ln -s ../../../tags tags'
|
|
}
|
|
dir("${projectRoot}/gerby-website/") {
|
|
sh 'rm ./hello-world.sqlite || true'
|
|
sh 'rm ./comments.sqlite || true'
|
|
sh 'ln -s gerby/tools/hello-world.sqlite hello-world.sqlite'
|
|
sh 'ln -s gerby/tools/comments.sqlite comments.sqlite'
|
|
}
|
|
}
|
|
}
|
|
stage('Bibliography') {
|
|
steps {
|
|
dir("${projectRoot}/") {
|
|
sh 'pdflatex -interaction=nonstopmode document.tex || true'
|
|
sh 'bibtex document || true'
|
|
sh 'pdflatex -interaction=nonstopmode document.tex || true'
|
|
}
|
|
}
|
|
}
|
|
stage('Delete Tags') {
|
|
when {
|
|
expression { params['Redo Tags'] == true }
|
|
}
|
|
steps {
|
|
dir("${projectRoot}/") {
|
|
sh 'rm ./tags || true'
|
|
sh 'rm ./gerby-website/gerby/tools/hello-world.sqlite || true'
|
|
}
|
|
}
|
|
}
|
|
// The document folder is needed for the website to run, hence it is not cleared at the end of the compile process.
|
|
stage('Delete Previous Build') {
|
|
steps {
|
|
dir("${projectRoot}/") {
|
|
sh "rm -r ./document"
|
|
}
|
|
}
|
|
}
|
|
stage('Tag') {
|
|
steps {
|
|
dir("${projectRoot}/") {
|
|
sh "${vGPython} tagger.py >> tags"
|
|
}
|
|
}
|
|
}
|
|
stage('Plastex') {
|
|
steps {
|
|
dir("${projectRoot}/") {
|
|
sh "${vPlastex} --renderer=Gerby ./document.tex"
|
|
}
|
|
}
|
|
}
|
|
stage('Update Database') {
|
|
steps {
|
|
dir("${projectRoot}/gerby-website/gerby/tools") {
|
|
sh "${vGPython} update.py"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
always {
|
|
dir("${projectRoot}/") {
|
|
sh 'rm document.aux || true'
|
|
sh 'rm document.bbl || true'
|
|
sh 'rm document.blg || true'
|
|
sh 'rm document.log || true'
|
|
sh 'rm document.out || true'
|
|
sh 'rm document.pdf || true'
|
|
}
|
|
script {
|
|
def formatTime = { milliseconds ->
|
|
long seconds = (long)(milliseconds / 1000)
|
|
long mins = (long)(seconds / 60)
|
|
long secs = seconds % 60
|
|
return mins > 0 ? "${mins}m${secs}s" : "${secs}s"
|
|
}
|
|
|
|
def buildTitle = "Build Website #${env.BUILD_NUMBER}"
|
|
if (params['Redo Tags']) {
|
|
buildTitle += " (Retag)"
|
|
}
|
|
|
|
def queueTimeMs = currentBuild.startTimeInMillis - currentBuild.timeInMillis
|
|
def queueTime = formatTime(queueTimeMs)
|
|
def buildTime = formatTime(currentBuild.duration)
|
|
|
|
def description = """
|
|
**Build:** [#${env.BUILD_NUMBER}](${env.BUILD_URL})
|
|
**Console:** [Console Output](${env.BUILD_URL}console)
|
|
|
|
**Queue Time:** ${queueTime}
|
|
**Build Duration:** ${buildTime}
|
|
**Status:** ${currentBuild.currentResult}
|
|
""".trim()
|
|
|
|
discordSend(
|
|
webhookURL: discordHook,
|
|
title: buildTitle,
|
|
description: description,
|
|
result: currentBuild.currentResult
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|