From 1a84fc454a9f10d2df05e1f8e8ced2cd6938a347 Mon Sep 17 00:00:00 2001 From: Patryk Gudalewicz Date: Fri, 28 Oct 2022 09:43:46 +0200 Subject: [PATCH] Adding Jenkinsfile, adjusting environment.yaml --- Jenkinsfile | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ environment.yaml | 31 +++++++++++++++++-- 2 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..5c47c1a --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,77 @@ +pipeline { + options { + ansiColor('xterm') + } + //label libraryBuild is available in CN JAWS and ROW JAWS, therefore this one was used; no additional intents + agent {label 'libraryBuild'} + parameters { + string(name: 'CLUSTER', defaultValue: '', description: 'Enter the cluster name') + + string(name: 'ENVIRONMENT', defaultValue: '', description: 'Enter single environment name. Possible values are: euprod, eupreprod, napreprod, naprod, cnprod. cnpreprod') + + } + + //here comes the trigger according to crontabs - jenkins is in UTC + triggers { + + } + 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}" + + 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') + + } + + stages { + stage('install required python packages') { + steps { + sh ''' + pip install --user -r requirements.txt + ''' + print env.JENKINS_URL + } + } + + stage('Execute Dashboard script') { + steps { + if(CLUSTER.isEmpty()) { + currentBuild.result = 'ABORTED' + error('Aborting due to missing CLUSTER parameter') + return + } + else if(ENVIRONMENT.isEmpty()) { + currentBuild.result = 'ABORTED' + error('Aborting due to missing ENVIRONMENT parameter') + return + } + else { + SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -C " + CLUSTER.toString() + SCRIPT_PARAMETER = SCRIPT_PARAMETER + " -E " + ENVIRONMENT.toString() + sh "python createDash.py ${SCRIPT_PARAMETER}" + } + + } + + } + } + + post { + always { + cleanWs() + } + } +} \ No newline at end of file diff --git a/environment.yaml b/environment.yaml index 07a4028..5c069d8 100644 --- a/environment.yaml +++ b/environment.yaml @@ -1,4 +1,31 @@ +--- +euprod: + - name: "euprod" + - env-url: "https://xxu26128.live.dynatrace.com" + - env-token-name: "EUPROD_TOKEN_VAR" + - jenkins: "https://jaws.bmwgroup.net/opapm/" eupreprod: - name: "eupreprod" - - env-url: "https://qqk70169.live.dynatrace.com/" - - env-token-name: "EMEA_PREPROD_CONFIG_TOKEN" \ No newline at end of file + - env-url: "https://qqk70169.live.dynatrace.com" + - env-token-name: "EUPREPROD_TOKEN_VAR" + - jenkins: "https://jaws.bmwgroup.net/opapm/" +napreprod: + - name: "napreprod" + - env-url: "https://onb44935.live.dynatrace.com" + - env-token-name: "NAPREPROD_TOKEN_VAR" + - jenkins: "https://jaws.bmwgroup.net/opapm/" +naprod: + - name: "naprod" + - env-url: "https://wgv50241.live.dynatrace.com" + - env-token-name: "NAPROD_TOKEN_VAR" + - jenkins: "https://jaws.bmwgroup.net/opapm/" +cnprod: + - name: "cnprod" + - env-url: "https://dyna-synth-cn.bmwgroup.com.cn/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b" + - env-token-name: "CNPROD_TOKEN_VAR" + - jenkins: "https://jaws-china.bmwgroup.net/opmaas/" +cnpreprod: + - name: "cnpreprod" + - env-url: "https://dynatracemgd-tsp.bmwgroup.net/e/ab88c03b-b7fc-45f0-9115-9e9ecc0ced35" + - env-token-name: "CNPREPROD_TOKEN_VAR" + - jenkins: "https://jaws-china.bmwgroup.net/opmaas/"