From cd53d0856e8fcd765a614059a07211327f735f0c Mon Sep 17 00:00:00 2001 From: "SLW\\ARNAUA" Date: Thu, 1 Jun 2023 12:44:00 +0200 Subject: [PATCH] env variables --- Jenkinsfile | 28 ++++++++++++++-------------- export.py | 5 ++--- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 50254b5..ade4202 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,18 +19,18 @@ pipeline { AUTH = credentials('proxy') proxy_user = "${AUTH_USR}" proxy_pw = "${AUTH_PSW}" - EMEA_PROD_API_TOKEN = credentials('EUPROD_TOKEN_VAR') - EMEA_PROD_ENV_URL = 'https://xxu26128.live.dynatrace.com' - EMEA_PREPROD_API_TOKEN = credentials('EUPREPROD_TOKEN_VAR') - EMEA_PREPROD_ENV_URL = 'https://qqk70169.live.dynatrace.com' - NA_PROD_API_TOKEN = credentials('NAPROD_TOKEN_VAR') - NA_PROD_ENV_URL = 'https://wgv50241.live.dynatrace.com' - NA_PREPROD_API_TOKEN = credentials('NAPREPROD_TOKEN_VAR') - NA_PREPROD_ENV_URL = 'https://onb44935.live.dynatrace.com' - CN_PROD_API_TOKEN = credentials('CNPROD_TOKEN_VAR') - CN_PROD_ENV_URL= 'https://dynatracemgd-tsp.bmwgroup.net/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b' - CN_PREPROD_API_TOKEN = credentials('CNPREPROD_TOKEN_VAR') - CN_PREPROD_ENV_URL = 'https://dynatracemgd-tsp.bmwgroup.net/e/ab88c03b-b7fc-45f0-9115-9e9ecc0ced35' + env.EMEA_PROD_API_TOKEN = credentials('EUPROD_TOKEN_VAR') + env.EMEA_PROD_ENV_URL = 'https://xxu26128.live.dynatrace.com' + env.EMEA_PREPROD_API_TOKEN = credentials('EUPREPROD_TOKEN_VAR') + env.EMEA_PREPROD_ENV_URL = 'https://qqk70169.live.dynatrace.com' + env.NA_PROD_API_TOKEN = credentials('NAPROD_TOKEN_VAR') + env.NA_PROD_ENV_URL = 'https://wgv50241.live.dynatrace.com' + env.NA_PREPROD_API_TOKEN = credentials('NAPREPROD_TOKEN_VAR') + env.NA_PREPROD_ENV_URL = 'https://onb44935.live.dynatrace.com' + env.CN_PROD_API_TOKEN = credentials('CNPROD_TOKEN_VAR') + env.CN_PROD_ENV_URL= 'https://dynatracemgd-tsp.bmwgroup.net/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b' + env.CN_PREPROD_API_TOKEN = credentials('CNPREPROD_TOKEN_VAR') + env.CN_PREPROD_ENV_URL = 'https://dynatracemgd-tsp.bmwgroup.net/e/ab88c03b-b7fc-45f0-9115-9e9ecc0ced35' } stages { @@ -75,7 +75,7 @@ pipeline { stage('Install Required Packages') { steps { - dir("/opt/workspace/coco_apm_dynatrace_terraform_backup_exporter") { + dir("/opt/workspace/coco_apm_dynatrace_terraform_backup_exporter/") { retry(3) { sleep(300*installRetryCount) script { @@ -94,7 +94,7 @@ pipeline { stage('Execute Exporting Script') { steps { - dir("/opt/workspace/coco_apm_dynatrace_terraform_backup_exporter") { + dir("/opt/workspace/coco_apm_dynatrace_terraform_backup_exporter/") { retry(3) { sleep(300*exportRetryCount) script { diff --git a/export.py b/export.py index c34b4d6..a09d039 100644 --- a/export.py +++ b/export.py @@ -9,8 +9,8 @@ from glob import glob def setEnv(env, time, path, dashboard): - os.environ['DYNATRACE_ENV_URL'] = str(os.getenv(env + "_ENV_URL",default=str(env + "_ENV_URL"))) - os.environ['DYNATRACE_API_TOKEN'] = str(os.getenv(env + "_API_TOKEN")) + os.environ['DYNATRACE_ENV_URL'] = str(os.environ.get(env + "_ENV_URL")) + os.environ['DYNATRACE_API_TOKEN'] = str(os.environ.get(env + "_API_TOKEN")) os.environ['DYNATRACE_TARGET_FOLDER'] = str(path + time + "_" + env + dashboard) return os.environ @@ -42,7 +42,6 @@ def runProcess(process_name, input_params): if __name__ == "__main__": if(len(sys.argv) == 1): - print(os.getcwd()) timestamp = time.strftime("%Y%m%d-%H%M%S") outputFolder = "./output/" environments = ["EMEA_PROD", "EMEA_PREPROD", "NA_PROD", "NA_PREPROD", "CN_PROD", "CN_PREPROD"]