htlle-da-vorlage/Jenkinsfile

73 lines
2.4 KiB
Plaintext
Raw Normal View History

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-16 22:43:53 +02:00
skipDefaultCheckout()
2020-04-16 14:08:44 +02:00
}
parameters {
string(name: 'USERNAME', defaultValue: 'Username', description: 'Benutzername')
password(name: 'PASSWORD', defaultValue: '', description: 'Passwort')
2020-04-16 23:30:17 +02:00
string(name: 'REPOSITORY', defaultValue: '.git', description: 'URL Git-Repository DA \n default Wert: Baue Vorlage \n Ohne https://')
2020-04-16 19:56:11 +02:00
string(name: 'PATH', defaultValue: '', description: "Pfad zur DA in git (z.B.: dipl/)")
2020-04-16 14:08:44 +02:00
}
stages {
2020-04-16 15:54:33 +02:00
stage('Clean checkout of the template') {
when {
expression { '.git' == params.REPOSITORY }
}
2020-04-16 15:54:33 +02:00
steps{
cleanWs()
checkout scm
}
}
2020-04-16 20:26:24 +02:00
stage('Build only template') {
when {
expression { '.git' == params.REPOSITORY }
}
steps {
sh '''
cp -rv HTLLE-DA-Vorlage/example/* .
make pdf -C HTLLE-DA-Vorlage SOURCEDIR=$(pwd)
'''
}
}
2020-04-16 14:08:44 +02:00
stage('Checkout DA') {
when {
expression { '.git' != params.REPOSITORY }
}
steps {
2020-04-16 23:18:11 +02:00
cleanWs()
2020-04-16 14:08:44 +02:00
sh '''
2020-04-16 23:30:17 +02:00
login_url_sub="https://"${params.USERNAME}":"${params.PASSWORD}"@"${params.REPOSITORY}
git clone --recurse-submodules --remote-submodules ${login_url_sub} .
2020-04-16 14:08:44 +02:00
'''
}
}
stage('Build DA') {
when {
expression { '.git' != params.REPOSITORY }
}
steps {
sh '''
2020-04-16 23:04:02 +02:00
cd ${params.PATH}
2020-04-16 14:08:44 +02:00
make pdf -C HTLLE-DA-Vorlage SOURCEDIR=$(pwd)
'''
}
}
stage('Test if diplomarbeit.pdf was build') {
steps {
2020-04-16 15:54:33 +02:00
sh "test -f diplomarbeit.pdf"
2020-04-16 14:08:44 +02:00
}
}
}
post {
2020-04-16 14:11:06 +02:00
always {
2020-04-16 17:01:45 +02:00
emailext attachLog: true, attachmentsPattern: 'diplomarbeit.pdf*',
2020-04-16 14:08:44 +02:00
body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}",
recipientProviders: [requestor()],
subject: "Jenkins Diplomarbeit Build ${currentBuild.currentResult}"
}
}
}