Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-report
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tools
gitlab-report
Commits
4e7d4585
Commit
4e7d4585
authored
1 year ago
by
Sigmund, Dominik
Browse files
Options
Downloads
Patches
Plain Diff
Update 2 files
- /.env - /script.py
parent
43fea6da
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.env
+1
-0
1 addition, 0 deletions
.env
script.py
+15
-17
15 additions, 17 deletions
script.py
with
16 additions
and
17 deletions
.env
+
1
−
0
View file @
4e7d4585
GITLAB_API_TOKEN=your_gitlab_api_token_here
CONFLUENCE_API_TOKEN=your_confluence_api_token_here
\ No newline at end of file
This diff is collapsed.
Click to expand it.
script.py
+
15
−
17
View file @
4e7d4585
...
...
@@ -10,12 +10,8 @@ from dotenv import load_dotenv
gitlab_url
=
'
https://gitlab.ard.de
'
confluence_url
=
'
YOUR_CONFLUENCE_URL
'
api_token
=
'
YOUR_API_TOKEN
'
sender_email
=
'
your_email@example.com
'
sender_password
=
'
your_email_password
'
recipient_email
=
'
recipient@example.com
'
sender_email
=
'
gitlab-report@br.de
'
recipient_email
=
'
dominik.sigmund@br.de
'
def
check_binaries
():
required_binaries
=
[
'
df
'
,
'
gitlab-ctl
'
]
...
...
@@ -31,10 +27,16 @@ def load_api_token():
api_token
=
os
.
getenv
(
'
GITLAB_API_TOKEN
'
)
if
not
api_token
:
print
(
"
Error: API token not found in .env file.
"
)
print
(
"
Error: Gitlab API token not found in .env file.
"
)
exit
(
1
)
confluence_token
=
os
.
getenv
(
'
CONFLUENCE_API_TOKEN
'
)
if
not
confluence_token
:
print
(
"
Error: Confluence API token not found in .env file.
"
)
exit
(
1
)
return
api_token
return
api_token
,
confluence_token
def
get_disk_space
():
# Run the df command to get disk space information
...
...
@@ -169,12 +171,8 @@ def send_email(sender_email, sender_password, recipient_email, subject, body):
# Attach the HTML content to the email
msg
.
attach
(
MIMEText
(
html_table
,
'
html
'
))
# Send the email
server
=
smtplib
.
SMTP
(
'
smtp.gmail.com
'
,
587
)
server
.
starttls
()
server
.
login
(
sender_email
,
sender_password
)
server
.
sendmail
(
sender_email
,
recipient_email
,
msg
.
as_string
())
server
.
quit
()
with
smtplib
.
SMTP
(
'
localhost
'
)
as
server
:
server
.
sendmail
(
sender_email
,
recipient_email
,
msg
.
as_string
())
def
create_blog_post
(
confluence_url
,
api_token
,
blog_post_content
):
headers
=
{
...
...
@@ -216,7 +214,7 @@ def create_blog_post(confluence_url, api_token, blog_post_content):
# Check if required binaries are available
check_binaries
()
api_token
=
load_api_token
()
api_token
,
confluence_token
=
load_api_token
()
subject
=
'
Monthly GitLab Report - {month} {year}
'
.
format
(
month
=
datetime
.
datetime
.
now
().
strftime
(
'
%B
'
),
year
=
datetime
.
datetime
.
now
().
strftime
(
'
%Y
'
))
...
...
@@ -236,7 +234,7 @@ email_body = {
}
# Send the email
send_email
(
sender_email
,
sender_password
,
recipient_email
,
subject
,
email_body
)
send_email
(
sender_email
,
recipient_email
,
subject
,
email_body
)
# create blog post
blog_post_id
=
create_blog_post
(
confluence_url
,
api_token
,
email_body
)
\ No newline at end of file
# blog_post_id = create_blog_post(confluence_url, api_token, email_body)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment