add some vars clean up code

This commit is contained in:
Clemens Lauermann 2020-04-20 10:16:24 +02:00
parent 1f7907f0d2
commit ed3c301872

32
Jenkinsfile vendored
View File

@ -9,7 +9,7 @@ pipeline {
parameters {
string(
name: 'REPOSITORY',
defaultValue: 'itsp.htl-leoben.at/git/Hg/HTLLE-DA-Vorlage.git',
defaultValue: 'https://itsp.htl-leoben.at/git/Hg/HTLLE-DA-Vorlage.git',
description: 'URL git-Repository DA//'
)
string(
@ -25,10 +25,13 @@ pipeline {
}
stages {
stage('Checkout DA') {
stage('Set some variables'){
steps{
cleanWs()
script {
// set template values
env.TEMPLATE_URL = 'https://itsp.htl-leoben.at/git/Hg/HTLLE-DA-Vorlage.git'
env.TEMPLATE_NAME = 'HTLLE-DA-Vorlage'
// add https to the url if not present
env.REPOSITORY = params.REPOSITORY
if(!env.REPOSITORY.startsWith("https://")) {
@ -48,6 +51,11 @@ pipeline {
// be sure branch is set
env.GIT_BRANCH = params.GIT_BRANCH ?: '*/master'
}
}
}
stage('Checkout DA') {
steps {
cleanWs()
// checkout out the repository including submodules
// builduser acc used in git
checkout([
@ -73,26 +81,26 @@ pipeline {
}
stage('Build DA') {
when {
expression { 'https://itsp.htl-leoben.at/git/Hg/HTLLE-DA-Vorlage.git' != env.REPOSITORY }
expression { env.TEMPLATE_URL != env.REPOSITORY }
}
steps {
dir(env.GIT_PATH) {
sh 'make pdf -C HTLLE-DA-Vorlage SOURCEDIR=$(pwd)'
sh "make pdf -C ${env.TEMPLATE_NAME} SOURCEDIR=`pwd`"
}
}
}
stage('Build only template') {
when {
expression { 'https://itsp.htl-leoben.at/git/Hg/HTLLE-DA-Vorlage.git' == env.REPOSITORY }
expression { env.TEMPLATE_URL == env.REPOSITORY }
}
steps {
// build the template with the examples from DA point of view
sh '''#!/bin/bash
mkdir HTLLE-DA-Vorlage
ls | grep -v HTLLE-DA-Vorlage | xargs mv -t HTLLE-DA-Vorlage
cp -rv HTLLE-DA-Vorlage/example/. .
make pdf -C HTLLE-DA-Vorlage SOURCEDIR=$(pwd)
'''
sh """#!/bin/bash
mkdir ${env.TEMPLATE_NAME}
ls | grep -v ${env.TEMPLATE_NAME} | xargs mv -t ${env.TEMPLATE_NAME}
cp -rv ${env.TEMPLATE_NAME}/example/. .
make pdf -C ${env.TEMPLATE_NAME} SOURCEDIR=`pwd`
"""
}
}
stage('Test if diplomarbeit.pdf exists') {