2020-04-16 14:08:44 +02:00
|
|
|
pipeline {
|
|
|
|
agent { label 'docker-lehrer' }
|
2020-04-16 22:43:53 +02:00
|
|
|
|
2020-04-16 14:08:44 +02:00
|
|
|
options {
|
|
|
|
buildDiscarder(logRotator(artifactNumToKeepStr: '0'))
|
2020-04-17 09:07:55 +02:00
|
|
|
skipDefaultCheckout(true)
|
2020-04-16 14:08:44 +02:00
|
|
|
}
|
2020-04-19 10:32:47 +02:00
|
|
|
|
2020-04-16 14:08:44 +02:00
|
|
|
parameters {
|
2020-04-19 10:32:47 +02:00
|
|
|
string(
|
|
|
|
name: 'REPOSITORY',
|
2020-04-20 10:16:24 +02:00
|
|
|
defaultValue: 'https://itsp.htl-leoben.at/git/Hg/HTLLE-DA-Vorlage.git',
|
2020-04-19 10:32:47 +02:00
|
|
|
description: 'URL git-Repository DA//'
|
2020-04-19 18:50:53 +02:00
|
|
|
)
|
2020-04-19 10:32:47 +02:00
|
|
|
string(
|
|
|
|
name: 'GIT_PATH',
|
|
|
|
defaultValue: './',
|
|
|
|
description: "Pfad zur DA in git (z.B.: dipl/)"
|
2020-04-19 18:50:53 +02:00
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'GIT_BRANCH',
|
|
|
|
defaultValue: '*/master',
|
|
|
|
description: "Expert: Wenn Sie einen anderen als den 'master' Branch bauen möchten"
|
|
|
|
)
|
2020-04-16 14:08:44 +02:00
|
|
|
}
|
2020-04-19 10:32:47 +02:00
|
|
|
|
2020-04-16 14:08:44 +02:00
|
|
|
stages {
|
2020-04-20 10:42:59 +02:00
|
|
|
stage('Set some variables and clean workspace'){
|
2020-04-20 10:16:24 +02:00
|
|
|
steps{
|
2020-04-20 10:42:59 +02:00
|
|
|
cleanWs()
|
2020-04-19 10:32:47 +02:00
|
|
|
script {
|
2020-04-20 10:16:24 +02:00
|
|
|
// set template values
|
|
|
|
env.TEMPLATE_URL = 'https://itsp.htl-leoben.at/git/Hg/HTLLE-DA-Vorlage.git'
|
|
|
|
env.TEMPLATE_NAME = 'HTLLE-DA-Vorlage'
|
|
|
|
|
2020-04-19 10:32:47 +02:00
|
|
|
// add https to the url if not present
|
|
|
|
env.REPOSITORY = params.REPOSITORY
|
|
|
|
if(!env.REPOSITORY.startsWith("https://")) {
|
|
|
|
env.REPOSITORY = "https://" + env.REPOSITORY
|
|
|
|
}
|
|
|
|
// sanitize git dir path
|
|
|
|
env.GIT_PATH = params.GIT_PATH
|
|
|
|
if(!env.GIT_PATH.endsWith("/")) {
|
|
|
|
env.GIT_PATH += "/"
|
|
|
|
}
|
|
|
|
if(env.GIT_PATH.startsWith("/")) {
|
|
|
|
env.GIT_PATH = env.GIT_PATH.substring(1)
|
|
|
|
}
|
|
|
|
if(env.GIT_PATH.startsWith("~/")) {
|
2020-04-21 00:15:21 +02:00
|
|
|
env.GIT_PATH = env.GIT_PATH.substring(2)
|
2020-04-19 10:32:47 +02:00
|
|
|
}
|
2020-04-21 00:15:21 +02:00
|
|
|
if(env.GIT_PATH.contains("../")) {
|
|
|
|
error("GIT_PATH must not contain '../'")
|
|
|
|
]
|
|
|
|
|
2020-04-19 18:50:53 +02:00
|
|
|
// be sure branch is set
|
|
|
|
env.GIT_BRANCH = params.GIT_BRANCH ?: '*/master'
|
2020-04-17 09:07:55 +02:00
|
|
|
}
|
2020-04-20 10:16:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Checkout DA') {
|
2020-04-20 10:42:59 +02:00
|
|
|
when {
|
|
|
|
expression { env.TEMPLATE_URL != env.REPOSITORY }
|
|
|
|
}
|
2020-04-20 10:16:24 +02:00
|
|
|
steps {
|
2020-04-19 10:32:47 +02:00
|
|
|
// checkout out the repository including submodules
|
|
|
|
// builduser acc used in git
|
|
|
|
checkout([
|
|
|
|
$class: 'GitSCM',
|
2020-04-19 18:50:53 +02:00
|
|
|
branches: [[name: "${env.GIT_BRANCH}"]],
|
2020-04-19 10:32:47 +02:00
|
|
|
doGenerateSubmoduleConfigurations: false,
|
|
|
|
extensions: [[
|
|
|
|
$class: 'SubmoduleOption',
|
2020-04-20 10:42:59 +02:00
|
|
|
disableSubmodules: true,
|
2020-04-19 10:32:47 +02:00
|
|
|
parentCredentials: true,
|
2020-04-20 10:42:59 +02:00
|
|
|
recursiveSubmodules: false,
|
|
|
|
shallow: true,
|
2020-04-19 10:32:47 +02:00
|
|
|
reference: '',
|
|
|
|
trackingSubmodules: false
|
|
|
|
]],
|
|
|
|
submoduleCfg: [],
|
|
|
|
userRemoteConfigs: [[
|
|
|
|
credentialsId: 'd65d903b-21ee-4055-98aa-ef82a903e287',
|
|
|
|
url: "${env.REPOSITORY}"
|
|
|
|
]]
|
|
|
|
])
|
2020-04-16 15:54:33 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-20 10:42:59 +02:00
|
|
|
stage('Checkout template') {
|
|
|
|
steps {
|
|
|
|
// remove template folder and fresh checkout
|
2020-04-20 13:24:40 +02:00
|
|
|
sh "rm -rf ${env.GIT_PATH}${env.TEMPLATE_NAME}"
|
2020-04-20 10:42:59 +02:00
|
|
|
checkout([
|
|
|
|
$class: 'GitSCM',
|
|
|
|
branches: [[name: '*/master']],
|
|
|
|
doGenerateSubmoduleConfigurations: false,
|
|
|
|
extensions: [[
|
|
|
|
$class: 'RelativeTargetDirectory',
|
|
|
|
relativeTargetDir: "${env.GIT_PATH}${env.TEMPLATE_NAME}"
|
|
|
|
]],
|
|
|
|
submoduleCfg: [],
|
|
|
|
userRemoteConfigs: [[
|
|
|
|
credentialsId: 'd65d903b-21ee-4055-98aa-ef82a903e287',
|
|
|
|
url: "${env.TEMPLATE_URL}"
|
|
|
|
]]
|
|
|
|
])
|
|
|
|
}
|
|
|
|
}
|
2020-04-19 10:32:47 +02:00
|
|
|
stage('Build DA') {
|
2020-04-16 14:08:44 +02:00
|
|
|
when {
|
2020-04-20 10:16:24 +02:00
|
|
|
expression { env.TEMPLATE_URL != env.REPOSITORY }
|
2020-04-16 14:08:44 +02:00
|
|
|
}
|
|
|
|
steps {
|
2020-04-19 10:32:47 +02:00
|
|
|
dir(env.GIT_PATH) {
|
2020-04-20 10:16:24 +02:00
|
|
|
sh "make pdf -C ${env.TEMPLATE_NAME} SOURCEDIR=`pwd`"
|
2020-04-22 10:53:56 +02:00
|
|
|
sh "hunspell -d de_AT,de_AT_frami,en_US -l -t *.md > diplomarbeit.pdf.spellcheck.txt"
|
2020-04-19 10:32:47 +02:00
|
|
|
}
|
2020-04-16 14:08:44 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-19 10:32:47 +02:00
|
|
|
stage('Build only template') {
|
2020-04-16 14:08:44 +02:00
|
|
|
when {
|
2020-04-20 10:16:24 +02:00
|
|
|
expression { env.TEMPLATE_URL == env.REPOSITORY }
|
2020-04-16 14:08:44 +02:00
|
|
|
}
|
|
|
|
steps {
|
2020-04-19 10:32:47 +02:00
|
|
|
// build the template with the examples from DA point of view
|
2020-04-20 10:16:24 +02:00
|
|
|
sh """#!/bin/bash
|
|
|
|
cp -rv ${env.TEMPLATE_NAME}/example/. .
|
|
|
|
make pdf -C ${env.TEMPLATE_NAME} SOURCEDIR=`pwd`
|
|
|
|
"""
|
2020-04-16 14:08:44 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-19 10:32:47 +02:00
|
|
|
stage('Test if diplomarbeit.pdf exists') {
|
2020-04-16 14:08:44 +02:00
|
|
|
steps {
|
2020-04-19 10:32:47 +02:00
|
|
|
dir(env.GIT_PATH) {
|
2020-04-16 15:54:33 +02:00
|
|
|
sh "test -f diplomarbeit.pdf"
|
2020-04-19 10:32:47 +02:00
|
|
|
}
|
2020-04-16 14:08:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
post {
|
2020-04-16 14:11:06 +02:00
|
|
|
always {
|
2020-04-19 10:32:47 +02:00
|
|
|
script {
|
|
|
|
env.RECIPIENTS = ""
|
|
|
|
// get mail addresses
|
|
|
|
metadata = readFile(file: "${env.GIT_PATH}metadata.yaml").split('\n').each { line ->
|
|
|
|
if(line.contains("- build-notification:")) {
|
2020-04-19 12:37:02 +02:00
|
|
|
// remove yaml comments
|
|
|
|
if(line.contains('#')) {
|
|
|
|
line = line.substring(0, line.indexOf('#'))
|
|
|
|
}
|
2020-04-19 10:32:47 +02:00
|
|
|
def mailMatch = line =~ /[_A-Za-z0-9-]+(.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(.[A-Za-z0-9]+)*(.[A-Za-z]{2,})/
|
2020-04-19 12:37:02 +02:00
|
|
|
if(mailMatch) {
|
|
|
|
env.RECIPIENTS += (mailMatch[0][0] + ";")
|
|
|
|
}
|
2020-04-19 10:32:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-19 11:11:37 +02:00
|
|
|
dir(env.GIT_PATH) {
|
|
|
|
emailext attachmentsPattern: "diplomarbeit.pdf*",
|
|
|
|
to: "${env.RECIPIENTS}",
|
|
|
|
subject: "[${currentBuild.currentResult}] Diplomarbeit Build #${env.BUILD_NUMBER}",
|
|
|
|
body: "Job ${env.JOB_NAME}: ${env.JOB_URL}"
|
|
|
|
}
|
2020-04-16 14:08:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|