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

34
Jenkinsfile vendored
View File

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