jobs: added documentation pipeline as it is referenced in Jcasc
Signed-off-by: Marc Mattmüller <marc.mattmueller@netmodule.com>
This commit is contained in:
parent
4f35879604
commit
03c61198e6
|
|
@ -0,0 +1,128 @@
|
|||
// Loading code requires a NODE context
|
||||
// But we want the code accessible outside the node Context
|
||||
// So declare common (object created by the LOAD operation) outside the Node block.
|
||||
def common
|
||||
|
||||
|
||||
// declarative pipeline
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
parameters {
|
||||
string(name: 'VERSION', defaultValue: '', description: 'The version string of the documentation, e.g. 1.2.3 or empty for latest')
|
||||
booleanParam(name: 'DO_CLEAN_BUILD', defaultValue: false, description: 'do a clean build, i.e. remove any residuals')
|
||||
}
|
||||
|
||||
options {
|
||||
timeout(time: 1, unit: 'HOURS')
|
||||
disableConcurrentBuilds()
|
||||
buildDiscarder(logRotator(numToKeepStr: '5'))
|
||||
}
|
||||
|
||||
environment {
|
||||
DOC_DIRNAME = "doc"
|
||||
DOC_DIR = "${WORKSPACE}/${DOC_DIRNAME}"
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
// Check Parameters
|
||||
//-----------------------------
|
||||
stage('Check Parameters') {
|
||||
steps {
|
||||
script {
|
||||
// load common file
|
||||
common = load "${WORKSPACE}/jobs/Jenkinsfile_Common"
|
||||
printJobParameters()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clean
|
||||
//-----------------------------
|
||||
stage('Clean') {
|
||||
when { expression { return params.DO_CLEAN_BUILD } }
|
||||
steps {
|
||||
script {
|
||||
common.cleaningClonedRepoDir()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare
|
||||
//-----------------------------
|
||||
stage('Prepare') {
|
||||
steps {
|
||||
script{
|
||||
setupEnvironment(common, "${params.VERSION}")
|
||||
printEnvironmentParameters()
|
||||
setDisplayName()
|
||||
}
|
||||
}
|
||||
} // Prepare
|
||||
|
||||
|
||||
// Build Doc
|
||||
//-----------------------------
|
||||
stage('Build Documentation') {
|
||||
steps {
|
||||
script {
|
||||
buildDocumentation("${env.DOC_DIR}", "CI Documentation")
|
||||
} // script
|
||||
}
|
||||
} // Build Doc
|
||||
|
||||
} // stages
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
def printJobParameters() {
|
||||
println "\
|
||||
----------------------------------\n\
|
||||
Job Parameters:\n\
|
||||
----------------------------------\n\
|
||||
VERSION = ${params.VERSION}\n\
|
||||
DO_CLEAN_BUILD = ${params.DO_CLEAN_BUILD}\n\
|
||||
----------------------------------\n"
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
def setupEnvironment(commonHelpers, version) {
|
||||
env.DOC_VERSION = ("${version}" == "") ? "latest" : "${version}"
|
||||
sh("rm -rf ${DOC_DIRNAME}/*.zip")
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
def setDisplayName() {
|
||||
currentBuild.displayName = "#${env.BUILD_NUMBER}: ${env.DOC_VERSION}"
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
def printEnvironmentParameters() {
|
||||
println "----------------------------------\n\
|
||||
Environment Parameters:\n\
|
||||
\n\
|
||||
--> doc version = ${env.DOC_VERSION}\n\
|
||||
--> doc dir = ${env.DOC_DIR}\n\
|
||||
----------------------------------\n"
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
def buildDocumentation(workDir, docTitle) {
|
||||
def artifactName = "NWL-CI-Doc-${env.DOC_VERSION}.zip"
|
||||
println "Building documentation for ${workDir}..."
|
||||
dir(workDir) {
|
||||
sh("make clean")
|
||||
if(sh(returnStatus: true, script: "make html") != 0) {
|
||||
unstable("UNSTABLE: building ${workDir}")
|
||||
return
|
||||
}
|
||||
println "Archiving documentation (name = ${artifactName}) and publishing HTML..."
|
||||
zip(archive: true, dir: "out/html", glob: "**/*", zipFile: "${artifactName}")
|
||||
publishHTML target: [
|
||||
allowMissing: false,
|
||||
alwaysLinkToLastBuild: false,
|
||||
keepAll: true,
|
||||
reportDir: 'out/html',
|
||||
reportFiles: 'index.html',
|
||||
reportName: docTitle
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue