added jenkinsfile
parent
28bf6d6e8e
commit
47e610b5b7
|
|
@ -1,48 +1,20 @@
|
||||||
#from tracemalloc import start
|
|
||||||
from decouple import config
|
from decouple import config
|
||||||
import sys
|
import sys
|
||||||
import yaml
|
import yaml
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
import time
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
#import requests
|
|
||||||
#import openpyxl
|
|
||||||
import argparse
|
import argparse
|
||||||
import warnings
|
import warnings
|
||||||
import os
|
import os
|
||||||
#import re
|
|
||||||
#import glob
|
|
||||||
|
|
||||||
import dynatraceAPI
|
import dynatraceAPI
|
||||||
from pagination import Pagionation
|
from pagination import Pagionation
|
||||||
|
|
||||||
import types
|
import types
|
||||||
#import SLO
|
|
||||||
#from patterns.Pattern1 import Pattern1, Pattern2, Pattern3, Pattern4
|
|
||||||
#import urllib.parse
|
|
||||||
|
|
||||||
from key_request_parser import krparser
|
from key_request_parser import krparser
|
||||||
|
|
||||||
warnings.filterwarnings("ignore")
|
warnings.filterwarnings("ignore")
|
||||||
|
|
||||||
|
|
||||||
#patterns=[Pattern1(), Pattern2(), Pattern3(), Pattern4()]
|
|
||||||
|
|
||||||
# def get_request(url, headers):
|
|
||||||
# try:
|
|
||||||
# response = requests.get(url, headers=headers)
|
|
||||||
# response.raise_for_status()
|
|
||||||
# except requests.exceptions.HTTPError as errh:
|
|
||||||
# return "An Http Error occurred:" + repr(errh)
|
|
||||||
# except requests.exceptions.ConnectionError as errc:
|
|
||||||
# return "An Error Connecting to the API occurred:" + repr(errc)
|
|
||||||
# except requests.exceptions.Timeout as errt:
|
|
||||||
# return "A Timeout Error occurred:" + repr(errt)
|
|
||||||
# except requests.exceptions.RequestException as err:
|
|
||||||
# return "An Unknown Error occurred" + repr(err)
|
|
||||||
|
|
||||||
# return response
|
|
||||||
|
|
||||||
def getSLO(ENV, DTAPIToken, DTENV):
|
def getSLO(ENV, DTAPIToken, DTENV):
|
||||||
# DTENV = base url
|
# DTENV = base url
|
||||||
# DTAPIToken = sec token
|
# DTAPIToken = sec token
|
||||||
|
|
@ -100,7 +72,7 @@ def getStats(krs):
|
||||||
|
|
||||||
return ignored, noData_1M, noData_1W
|
return ignored, noData_1M, noData_1W
|
||||||
|
|
||||||
def main(slo_path):
|
def main():
|
||||||
|
|
||||||
resultSlos=[]
|
resultSlos=[]
|
||||||
|
|
||||||
|
|
@ -132,4 +104,4 @@ def main(slo_path):
|
||||||
write_to_excel(ignoerd, noData1M, noData1W)
|
write_to_excel(ignoerd, noData1M, noData1W)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main('./slo_parameter.yaml')
|
main()
|
||||||
|
|
@ -0,0 +1,166 @@
|
||||||
|
//not required right now as CN is reachable from EMEA as well
|
||||||
|
// def loopEnvironments(environments){
|
||||||
|
// 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')
|
||||||
|
// {
|
||||||
|
// envname = environments."${key}"[0].'name'
|
||||||
|
// envurl = environments."${key}"[1].'env-url'
|
||||||
|
// tokenname = environments."${key}"[2].'env-token-name'
|
||||||
|
|
||||||
|
// sh 'python createReport.py "${envname}"'
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
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 * *')
|
||||||
|
|
||||||
|
//every day at 08:00
|
||||||
|
//cron('0 8 * * *')
|
||||||
|
|
||||||
|
//every monday at 06:00
|
||||||
|
//cron('0 5 * * 2-5')
|
||||||
|
|
||||||
|
//parameterizedCron('0 10 * * * %PRESELECT=week;SLICES=tdhy')
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
//ProxySettings
|
||||||
|
AUTH = credentials('proxy')
|
||||||
|
proxy_user = "${AUTH_USR}"
|
||||||
|
proxy_pw = "${AUTH_PSW}"
|
||||||
|
|
||||||
|
EUPROD_TOKEN_VAR = credentials('EUPROD_TOKEN_VAR')
|
||||||
|
EUPREPROD_TOKEN_VAR = credentials('EUPREPROD_TOKEN_VAR')
|
||||||
|
NAPROD_TOKEN_VAR = credentials('NAPROD_TOKEN_VAR')
|
||||||
|
NAPREPROD_TOKEN_VAR = credentials('NAPREPROD_TOKEN_VAR')
|
||||||
|
CNPROD_TOKEN_VAR = credentials('CNPROD_TOKEN_VAR')
|
||||||
|
CNPREPROD_TOKEN_VAR = credentials('CNPREPROD_TOKEN_VAR')
|
||||||
|
// FROM_DATE="${params.FROMDATE}"
|
||||||
|
// TO_DATE="${params.TODATE}"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('install required python packages') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
pip3 install --user -r requirements.txt
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Execute Reporting Script') {
|
||||||
|
steps {
|
||||||
|
|
||||||
|
script{
|
||||||
|
// 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()}
|
||||||
|
|
||||||
|
// if (PRESELECT.isEmpty()) {
|
||||||
|
// if (FROMDATE=='') {
|
||||||
|
// currentBuild.result = 'ABORTED'
|
||||||
|
// error('Aborting due to missing startdate parameter')
|
||||||
|
// return
|
||||||
|
|
||||||
|
// }
|
||||||
|
// 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 + " -p " + PRESELECT.toString()}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// echo "${SCRIPT_PARAMETER}"
|
||||||
|
sh "python3 createKeyRequestReport.py"
|
||||||
|
|
||||||
|
// sh "python3 summary.py"
|
||||||
|
// summary = readFile('summary.txt').trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
stage('Send report') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
try {
|
||||||
|
tmp_body = "Please find the output of the weekly KeyRequests-Report attached </br></br>"
|
||||||
|
emailext subject: env.JOB_NAME,
|
||||||
|
mimeType: 'text/html',
|
||||||
|
body: tmp_body,
|
||||||
|
//to: 'michaela.jaeger@bmw.de, OOC-Support@bmwgroup.com, Andreas.DA.Danzer@partner.bmw.de',
|
||||||
|
//to: 'rene.forstner@nttdata.com, Andreas.DA.Danzer@partner.bmw.de, linnea.bickeboeller@partner.bmwgroup.com',
|
||||||
|
//to: 'rene.forstner@nttdata.com, stephan.oertelt@bmw.de, Mohammed.Abadel@bmw.de, michaela.jaeger@bmw.de',
|
||||||
|
//to: 'rene.forstner@nttdata.com, ermis.wieger@nttdata.com, patryk.gudalewicz.bp@nttdata.com',
|
||||||
|
//to: 'patryk.gudalewicz.bp@nttdata.com',
|
||||||
|
//to: 'rene.forstner@nttdata.com, ermis.wieger@nttdata.com, arnel.arnautovic@nttdata.com, patryk.gudalewicz.bp@nttdata.com, stephan.oertelt@bmw.de, Mohammed.Abadel@bmw.de, michaela.jaeger@bmw.de, OOC-Support@bmwgroup.com, Andreas.DB.Danzer@bmwgroup.com',
|
||||||
|
//to: 'ermis.wieger@nttdata.com, Andreas.DB.Danzer@bmwgroup.com, OOC-Support@bmwgroup.com, michaela.jaeger@bmw.de, thilo.bindel@bmwgroup.com',
|
||||||
|
to: 'ermis.wieger@nttdata.com',
|
||||||
|
replyTo: 'coco-apm@bmw.de',
|
||||||
|
attachmentsPattern: '*.xlsx'
|
||||||
|
|
||||||
|
}
|
||||||
|
catch ( mailExc ){
|
||||||
|
echo "Sending Email Failed: ${mailExc}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
failure {
|
||||||
|
emailext subject: "${env.JOB_NAME} build ${env.BUILD_ID} failed",
|
||||||
|
body: "QM report failed, see logs for details: ${env.BUILD_URL}",
|
||||||
|
to: 'ermis.wieger@nttdata.com'
|
||||||
|
//to: 'BMW.CoCo.Dynatrace@nttdata.com, ermis.wieger@nttdata.com, Andreas.DB.Danzer@bmwgroup.com'
|
||||||
|
// to post to the teams channel "0 - APM Service Desk" just uncomment the following command:
|
||||||
|
// office365ConnectorSend webhookUrl: "https://bmwgroup.webhook.office.com/webhookb2/483edc00-c925-4672-8088-8299a0139fca@ce849bab-cc1c-465b-b62e-18f07c9ac198/JenkinsCI/9aca6923685b40f794134853fcbe88f1/ff31bcee-96b3-4481-9bd8-4f74180b263b",
|
||||||
|
// message: "QM report failed, see logs for details: ${env.BUILD_URL}",
|
||||||
|
// status: 'Failure',
|
||||||
|
// color: "d00000"
|
||||||
|
}
|
||||||
|
always {
|
||||||
|
cleanWs()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,4 +4,4 @@ pandas
|
||||||
requests
|
requests
|
||||||
datetime
|
datetime
|
||||||
argparse
|
argparse
|
||||||
openpyxl
|
#openpyxl
|
||||||
Loading…
Reference in New Issue