diff --git a/.env b/.env index 09e7d682388014c756f04fb3207e7c843d946f46..d153aacee28365bccd5c79956582794a6b355635 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 acd686e98f501c2f6c0c41fc2c843040db8ec420..410f4f2bd3000fa6d7fd5b45dedb252f64d30f9f 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'))