From 98b340f4126edee3c6f7d56973f441eb74885e21 Mon Sep 17 00:00:00 2001 From: "Sigmund, Dominik" <dominik.sigmund@br.de> Date: Mon, 31 Jul 2023 13:52:19 +0000 Subject: [PATCH] Update 2 files - /.env - /script.py --- .env | 5 ++++- script.py | 27 ++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.env b/.env index 09e7d68..d153aac 100644 --- a/.env +++ b/.env @@ -1,2 +1,5 @@ +GITLAB_URL=your_gitlab_url GITLAB_API_TOKEN=your_gitlab_api_token_here -CONFLUENCE_API_TOKEN=your_confluence_api_token_here \ No newline at end of file +CONFLUENCE_API_TOKEN=your_confluence_api_token_here +SENDER_MAIL=your-sender-mail +RECIPIENT_MAIL=your-recipient-mail \ No newline at end of file diff --git a/script.py b/script.py index acd686e..410f4f2 100644 --- a/script.py +++ b/script.py @@ -10,11 +10,6 @@ import requests from dotenv import load_dotenv -gitlab_url = 'https://gitlab.ard.de' - -sender_email = 'ard-gitlab-report@br.de' -recipient_email = 'gitlab-oc@cn.ard.de' - def check_binaries(): required_binaries = ['df', 'gitlab-ctl'] missing_binaries = [binary for binary in required_binaries if not shutil.which(binary)] @@ -38,7 +33,25 @@ def load_api_token(): print("Error: Confluence API token not found in .env file.") exit(1) - return api_token, confluence_token + gitlab_url = os.getenv('GITLAB_URL') + + if not gitlab_url: + print("Error: Gitlab URL not found in .env file.") + exit(1) + + sender_mail = os.getenv('SENDER_MAIL') + + if not sender_mail: + print("Error: Sender email address not found in .env file.") + exit(1) + + recipient_email = os.getenv('RECIPIENT_MAIL') + + if not recipient_email: + print("Error: Recipient email address not found in .env file.") + exit(1) + + return api_token, confluence_token, gitlab_url, sender_mail, recipient_email def get_disk_space(): # Run the df command to get disk space information @@ -236,7 +249,7 @@ def create_blog_post(confluence_url, api_token, blog_post_content): # Check if required binaries are available check_binaries() -api_token, confluence_token = load_api_token() +api_token, confluence_token, gitlab_url, sender_email, recipient_email = load_api_token() subject = '[gitlab.ard.de] Monthly Report - {month} {year}'.format(month=datetime.datetime.now().strftime('%B'), year=datetime.datetime.now().strftime('%Y')) -- GitLab