From ed3c301872025f6fbbf0e9950e55c293d99020ce Mon Sep 17 00:00:00 2001 From: Clemens Lauermann Date: Mon, 20 Apr 2020 10:16:24 +0200 Subject: [PATCH] add some vars clean up code --- Jenkinsfile | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ecc4bfa..ddb577c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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') { - steps { - cleanWs() + stage('Set some variables'){ + steps{ 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') {