cleaned
parent
f4e26acdab
commit
93ba6d5054
|
|
@ -3,41 +3,38 @@
|
|||
print env.JENKINS_URL
|
||||
|
||||
environments.each{key, val ->
|
||||
|
||||
//Execute only if you are on the same environment
|
||||
//not required right now as CN is reachable from EMEA as well
|
||||
if (env.JENKINS_URL == environments."${key}"[3].'jenkins')
|
||||
{
|
||||
if(env.JENKINS_URL == environments."${key}"[3].'jenkins'){
|
||||
envname = environments."${key}"[0].'name'
|
||||
envurl = environments."${key}"[1].'env-url'
|
||||
tokenname = environments."${key}"[2].'env-token-name'
|
||||
|
||||
sh 'python createReport.py "${envname}"'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
def installRetryCount = 0
|
||||
def reportRetryCount = 0
|
||||
pipeline {
|
||||
|
||||
options {
|
||||
ansiColor('xterm')
|
||||
}
|
||||
|
||||
//label libraryBuild is available in CN JAWS and ROW JAWS, therefore this one was used; no additional intents
|
||||
// agent {label 'jaws-slaves'}
|
||||
agent {label 'jaws-slaves'}
|
||||
|
||||
parameters {
|
||||
string(name: 'FROMDATE', defaultValue: '', description: 'Enter from date in format YYYY-MM-DD e.g. 2021-11-01')
|
||||
|
||||
string(name: 'TODATE', defaultValue: '', description: 'Enter to date in format YYYY-MM-DD e.g. 2021-11-30')
|
||||
|
||||
string(name: 'PRESELECT', defaultValue: 'day', description: 'Enter week | month (without |) - auto selects the last full week or last full month')
|
||||
|
||||
string(name: 'SLICES', defaultValue: 'dh', description: 'Enter h | d | t | y (without spaces or |) - writes the slices hourly, daily, total or year to date into ecxel. given in any order')
|
||||
}
|
||||
|
||||
//here comes the trigger according to crontabs - jenkins is in UTC
|
||||
|
||||
triggers {
|
||||
//every 1st of every month at 00:00
|
||||
//cron('0 0 1 * *')
|
||||
|
|
@ -49,7 +46,6 @@ def reportRetryCount = 0
|
|||
cron('0 5 * * 0-7')
|
||||
|
||||
//parameterizedCron('0 10 * * * %PRESELECT=week;SLICES=tdhy')
|
||||
|
||||
}
|
||||
|
||||
environment {
|
||||
|
|
@ -63,7 +59,6 @@ def reportRetryCount = 0
|
|||
//HTTP_PROXY="${http_proxy}"
|
||||
//HTTPS_PROXY="${https_proxy}"
|
||||
//NO_PROXY="${no_proxy}"
|
||||
|
||||
EUPROD_TOKEN_VAR = credentials('EUPROD_TOKEN_VAR')
|
||||
EUPREPROD_TOKEN_VAR = credentials('EUPREPROD_TOKEN_VAR')
|
||||
NAPROD_TOKEN_VAR = credentials('NAPROD_TOKEN_VAR')
|
||||
|
|
@ -72,11 +67,10 @@ def reportRetryCount = 0
|
|||
CNPREPROD_TOKEN_VAR = credentials('CNPREPROD_TOKEN_VAR')
|
||||
FROM_DATE="${params.FROMDATE}"
|
||||
TO_DATE="${params.TODATE}"
|
||||
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('install required python packages') {
|
||||
stage('Install Python Packages') {
|
||||
steps {
|
||||
retry(3) {
|
||||
sleep(300*installRetryCount)
|
||||
|
|
@ -87,7 +81,6 @@ def reportRetryCount = 0
|
|||
pip3 install --user -r requirements.txt
|
||||
'''
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -95,52 +88,53 @@ def reportRetryCount = 0
|
|||
steps {
|
||||
retry(3) {
|
||||
sleep(300*reportRetryCount)
|
||||
|
||||
script {
|
||||
reportRetryCount = reportRetryCount+1
|
||||
def SCRIPT_PARAMETER = ''
|
||||
|
||||
if(SLICES.isEmpty()) {
|
||||
currentBuild.result = 'ABORTED'
|
||||
error('Aborting due to missing slice parameter')
|
||||
return
|
||||
} else {
|
||||
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -s " + SLICES.toString()
|
||||
}
|
||||
else {SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -s " + SLICES.toString()}
|
||||
|
||||
if (PRESELECT.isEmpty()) {
|
||||
if (FROMDATE=='') {
|
||||
currentBuild.result = 'ABORTED'
|
||||
error('Aborting due to missing startdate parameter')
|
||||
return
|
||||
|
||||
} else {
|
||||
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -f " + FROMDATE.toString()
|
||||
}
|
||||
else { SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -f " + FROMDATE.toString() }
|
||||
|
||||
if (TODATE=='') {
|
||||
currentBuild.result = 'ABORTED'
|
||||
error('Aborting due to missing enddate parameter')
|
||||
return
|
||||
} else {
|
||||
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -t " + TODATE.toString()
|
||||
}
|
||||
else {SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -t " + TODATE.toString()}
|
||||
|
||||
} else {
|
||||
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -p " + PRESELECT.toString()
|
||||
}
|
||||
else { SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -p " + PRESELECT.toString()}
|
||||
|
||||
|
||||
|
||||
|
||||
echo "${SCRIPT_PARAMETER}"
|
||||
sh "python3 createReport.py ${SCRIPT_PARAMETER}"
|
||||
|
||||
sh "python3 summary.py"
|
||||
summary = readFile('summary.txt').trim()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Only required once CN is not reachable from EMEA
|
||||
//loopEnvironments(environments)
|
||||
}
|
||||
|
||||
}
|
||||
stage('Send report') {
|
||||
|
||||
stage('Send Report') {
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
|
|
@ -157,9 +151,7 @@ def reportRetryCount = 0
|
|||
to: 'Arnel.Arnautovic@nttdata.com',
|
||||
replyTo: 'coco-apm@bmw.de',
|
||||
attachmentsPattern: '*.xlsx'
|
||||
|
||||
}
|
||||
catch ( mailExc ){
|
||||
} catch ( mailExc ) {
|
||||
echo "Sending Email Failed: ${mailExc}"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue