Compare commits

...

28 Commits

Author SHA1 Message Date
PATRYK GUDALEWICZ (ext.) fb5eec9317 Jenkinsfile edited online with Bitbucket
switching to python 3.9
2023-07-17 08:20:29 +00:00
PATRYK GUDALEWICZ (ext.) 4b971989a6 Jenkinsfile edited online with Bitbucket
Adding distutils reference during python installation
2023-07-17 07:26:29 +00:00
Peter Oehmichen be24c40b5b corrected Xibix Address 2023-07-04 09:15:16 +02:00
Andreas Danzer (DE-701) 8c6f0298c0 Jenkinsfile online editiert mit Bitbucket
added johann
2023-07-03 11:16:28 +00:00
Daniel Mikula a9fff61fa9 set recipients back to production 2023-07-03 11:59:48 +02:00
Daniel Mikula c7ca2d7f93 set recipients to test 2023-07-03 10:14:10 +02:00
SLW\ARNAUA 42c7907ec7 OPMAAS-4466 - Change recipient for reports 2023-06-21 12:17:00 +02:00
QXZ3NHY cc7d608852 set recipients to production 2023-06-20 12:07:27 +02:00
QXZ3NHY 719cf8e673 set recipients to production 2023-06-20 11:20:25 +02:00
QXZ3NHY b6320b8417 test - csv 2023-06-20 11:08:40 +02:00
QXZ3NHY 5a7543465d adjusted recipients 2023-06-20 08:29:43 +02:00
QXZ3NHY f4d5acbb87 set to production 2023-06-19 13:38:52 +02:00
QXZ3NHY b156bbc6aa adapted pipeline 2023-06-19 13:21:57 +02:00
ermisw ebca1c9d05 removed shared_donfiguration moving stage & added EMEASAAS Environment variable 2023-06-05 16:49:41 +02:00
SLW\ARNAUA 6b904db7b8 added retry mechanism 2023-05-08 12:27:55 +02:00
SLW\ARNAUA 78dfe8039a added andreas to email list 2023-05-05 09:45:47 +02:00
SLW\ARNAUA ee97f329ec added andreas to email list 2023-05-05 09:44:38 +02:00
SLW\ARNAUA 2ee2a0d73a added Ermis to mail list 2023-05-05 09:16:39 +02:00
SLW\ARNAUA eeb8526a02 modified 2023-05-05 09:14:12 +02:00
SLW\ARNAUA 43d6bc9cd8 modified 2023-05-04 10:16:07 +02:00
SLW\ARNAUA 6d16d0e3f0 modified 2023-05-04 09:24:01 +02:00
SLW\ARNAUA 2aff021d9f modified 2023-05-02 08:55:24 +02:00
SLW\ARNAUA 1503914972 modified 2023-05-02 08:50:21 +02:00
SLW\ARNAUA bc5e896cf4 modified 2023-04-27 11:52:46 +02:00
SLW\ARNAUA a2656fcc43 added shared_configuration repository 2023-04-26 14:50:51 +02:00
SLW\ARNAUA 1570efe571 cleaned 2023-04-26 10:47:04 +02:00
SLW\ARNAUA 9c1b272757 cleaned 2023-04-26 10:41:40 +02:00
SLW\ARNAUA 2c402d8d2b replaced Jenkinsfile 2023-04-25 13:28:10 +02:00
1 changed files with 128 additions and 108 deletions

236
Jenkinsfile vendored
View File

@ -1,184 +1,204 @@
//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}"'
}
}
}
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'}
def checkRetryCount = 0
def checkRetryCountSec = 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'}
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')
string(name: 'PRESELECT', defaultValue: 'week', description: 'Enter day | week | month (without |) - auto selects the last full day, week or month')
string(name: 'SLICES', defaultValue: 'dt', description: 'Enter h | d | t | y (without spaces or |) - writes the slices hourly, daily, total or year to date into excel given in any order')
string(name: 'KPI_EXTENSION', defaultValue: 'true', description: 'Enter true or false if the extension should be executed')
string(name: 'FORMATS', defaultValue: 'xc', description: 'Enter x | c (without spaces or |) - creates xlsx (x) and/or CSV (c) file - the csv file will include a reduced list (depending on target report)')
}
//here comes the trigger according to crontabs - jenkins is in UTC
// 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 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 * * 0-7')
cron('0 4 * * 1')
//parameterizedCron('0 10 * * * %PRESELECT=week;SLICES=tdhy')
// parameterizedCron('0 10 * * * %PRESELECT=week;SLICES=tdhy')
}
environment {
//ProxySettings
AUTH = credentials('proxy')
proxy_user = "${AUTH_USR}"
proxy_pw = "${AUTH_PSW}"
//http_proxy="http://${proxy_user}:${proxy_pw}@proxy.muc:8080"
//https_proxy="http://${proxy_user}:${proxy_pw}@proxy.muc:8080"
//no_proxy="localhost,127.0.0.1,.muc,.bmwgroup.net"
//HTTP_PROXY="${http_proxy}"
//HTTPS_PROXY="${https_proxy}"
//NO_PROXY="${no_proxy}"
AUTH = credentials('jaws_dynatrace_bitbuket_user')
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')
EUPRODSAAS_TOKEN_VAR = credentials('EUPRODSAAS_TOKEN_VAR')
FROM_DATE="${params.FROMDATE}"
TO_DATE="${params.TODATE}"
}
REPORT_TYPE="${params.PRESELECT}"
KPI_EXTENSION="${params.KPI_EXTENSION}"
}
stages {
stage('install required python packages') {
stage('Fetch Repositories') {
steps {
retry(3) {
sleep(300*installRetryCount)
script {
installRetryCount = installRetryCount+1
parallel 'Checkout Repositories': {
dir("/opt/workspace/shared_configuration/") {
retry(3) {
sleep(300*checkRetryCount)
script {
checkRetryCount = checkRetryCount + 1
}
git branch: "master", credentialsId: "jaws_dynatrace_bitbuket_user", url: "https://atc.bmwgroup.net/bitbucket/scm/opapm/shared_configuration.git"
}
}
dir("/opt/workspace/qm_report/") {
retry(3) {
sleep(300*checkRetryCountSec)
script {
checkRetryCountSec = checkRetryCountSec + 1
}
git branch: "main", credentialsId: "jaws_dynatrace_bitbuket_user", url: "https://atc.bmwgroup.net/bitbucket/scm/opapm/qm_report.git"
}
}
sh '''
pip3 install --user -r requirements.txt
'''
}
}
}
stage('Install Required Python Packages') {
steps {
dir("/opt/workspace/qm_report/") {
retry(3) {
sleep(60*installRetryCount)
script {
installRetryCount = installRetryCount+1
}
sh """
sudo add-apt-repository ppa:deadsnakes/ppa -y && \
sudo apt install python3.9 -y && \
sudo apt install python3.9-distutils -y && \
python3.9 --version
curl https://bootstrap.pypa.io/get-pip.py | python3.9
python3.9 -m pip --version
python3.9 -m pip install -r requirements.txt
python3.9 -m pip install git+https://${AUTH_USR}:${AUTH_PSW}@atc.bmwgroup.net/bitbucket/scm/opapm/keyrequestparser.git
"""
}
}
}
}
stage('Execute Reporting Script') {
steps {
dir("/opt/workspace/qm_report/") {
retry(3) {
sleep(300*reportRetryCount)
script{
script {
reportRetryCount = reportRetryCount+1
def SCRIPT_PARAMETER = ''
if(SLICES.isEmpty()) {
currentBuild.result = 'ABORTED'
error('Aborting due to missing slice parameter')
return
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()}
if (FORMATS.isEmpty()) {
currentBuild.result = 'ABORTED'
error('Aborting due to missing report format parameter')
return
} else {
SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -o " + FORMATS.toString()
}
echo "${SCRIPT_PARAMETER}"
sh "python3.9 createReport.py ${SCRIPT_PARAMETER}"
sh "python3.9 summary.py"
summary = readFile('summary.txt').trim()
echo "${SCRIPT_PARAMETER}"
sh "python3 createReport.py ${SCRIPT_PARAMETER}"
if (KPI_EXTENSION=='true') {
echo "Executing KPI Extension"
sh "python3.9 kpi_extension.py"
}
sh "python3 summary.py"
summary = readFile('summary.txt').trim()
}
}
//Only required once CN is not reachable from EMEA
//loopEnvironments(environments)
}
// Only required once CN is not reachable from EMEA
// loopEnvironments(environments)
}
}
}
stage('Send report') {
stage('Send Report') {
steps {
script {
try {
tmp_body = "Please find the output of the daily QM-Report attached </br></br>${summary}"
emailext subject: env.JOB_NAME,
dir("/opt/workspace/qm_report/") {
try {
emailext subject: "THE OFFICIAL ${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: 'Arnel.Arnautovic@nttdata.com',
replyTo: 'coco-apm@bmw.de',
attachmentsPattern: '*.xlsx'
}
catch ( mailExc ){
body: "Please find the output of the daily QM-Report attached </br></br>${summary}",
to: 'Ermis.Wieger@nttdata.com, Andreas.DB.Danzer@bmwgroup.com, OOC-Support@bmwgroup.com, Michaela.Jaeger@bmw.de, Thilo.Bindel@bmwgroup.com, Mohammed.Abadel@bmw.de, Jan.SC.Schaefer@bmw.de, omt-xibix@list.bmw.com, johann.wildgruber@bmwgroup.com',
// test:
// to: 'Daniel.Mikula@nttdata.com, Arnel.Arnautovic@nttdata.com',
replyTo: 'coco-apm@bmw.de',
attachmentsPattern: '*.xlsx, *.csv'
} 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: 'Arnel.Arnautovic@nttdata.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"
emailext subject: "THE OFFICIAL ${env.JOB_NAME} build ${env.BUILD_ID} failed",
body: "QM report failed, see logs for details: ${env.BUILD_URL}",
to: 'Arnel.Arnautovic@nttdata.com, Daniel.Mikula@nttdata.com, ops-xibix@list.bmw.com, omt-xibix@list.bmw.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 {
always {
cleanWs()
}
}