Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SonarQube Scripts
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Geant DevOps
SonarQube Scripts
Commits
eba95fef
Unverified
Commit
eba95fef
authored
1 year ago
by
Max Adamo
Browse files
Options
Downloads
Patches
Plain Diff
temporarily remove Nomad stuff
parent
ef15e310
No related branches found
No related tags found
No related merge requests found
Pipeline
#82129
failed
1 year ago
Stage: build
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitlab-ci.yml
+0
-3
0 additions, 3 deletions
.gitlab-ci.yml
config.py
+1
-3
1 addition, 3 deletions
config.py
sq_projects_list.py
+9
-9
9 additions, 9 deletions
sq_projects_list.py
webapp/__init__.py
+1
-3
1 addition, 3 deletions
webapp/__init__.py
webapp/routes.py
+6
-6
6 additions, 6 deletions
webapp/routes.py
with
17 additions
and
24 deletions
.gitlab-ci.yml
+
0
−
3
View file @
eba95fef
...
...
@@ -7,11 +7,8 @@ build:
IMAGE_TAG
:
$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
DOCKER_HOST
:
http://docker:2375/v1.24/auth
script
:
-
echo "hello 1"
-
echo "password is ${CI_REGISTRY_PASSWORD} and username is ${CI_REGISTRY_USER} and resgistry is ${CI_REGISTRY}"
-
echo "hello 2"
-
echo $CI_REGISTRY_PASSWORD | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin
#- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
-
docker build -t $CI_COMMIT_BRANCH.$CI_COMMIT_TIMESTAMP .
-
docker push $IMAGE_TAG
tags
:
...
...
This diff is collapsed.
Click to expand it.
config.py
+
1
−
3
View file @
eba95fef
...
...
@@ -3,8 +3,6 @@ basedir = os.path.abspath(os.path.dirname(__file__))
print
(
f
"
DEBUG: config
{
basedir
}
"
)
class
Config
(
object
):
"""
Base config class
"""
SQLALCHEMY_TRACK_MODIFICATIONS
=
False
INIT_LOCATION
=
'
/secrets/config.ini
'
# this is a test
This diff is collapsed.
Click to expand it.
sq_projects_list.py
+
9
−
9
View file @
eba95fef
...
...
@@ -26,14 +26,16 @@ def filter_data(data, months_nr):
date_obj
=
datetime
.
datetime
.
strptime
(
date_str
,
'
%Y-%m-%dT%H:%M:%S%z
'
)
months_diff
=
(
datetime
.
datetime
.
now
(
date_obj
.
tzinfo
)
-
date_obj
)
//
datetime
.
timedelta
(
days
=
30
)
)
//
datetime
.
timedelta
(
days
=
30
)
if
months_diff
>
months_nr
:
filtered_data
.
append
(
item
)
return
filtered_data
def
fetch_data
(
sq_ini
=
os
.
path
.
expanduser
(
'
~/.config/sonarqube.ini
'
)):
def
fetch_data
(
config_ini
=
os
.
path
.
expanduser
(
'
~/.config/sonarqube.ini
'
)):
"""
fetch data from SonarQube
"""
config
=
configparser
.
RawConfigParser
()
config
.
read
(
sq
_ini
)
config
.
read
(
config
_ini
)
sq_token
=
config
.
get
(
'
sq
'
,
'
token
'
)
sq_host
=
config
.
get
(
'
sq
'
,
'
host
'
)
session
=
requests
.
Session
()
...
...
@@ -47,21 +49,20 @@ def fetch_data(sq_ini = os.path.expanduser('~/.config/sonarqube.ini')):
raise
Exception
(
f
'
Error: HTTP status code is
{
req
.
status_code
}
'
)
proj_list
=
req
.
json
()[
'
components
'
]
final_lis
t
=
[]
list_ou
t
=
[]
for
project
in
proj_list
:
if
'
lastAnalysisDate
'
in
project
:
final_lis
t
.
append
({
list_ou
t
.
append
({
'
project_name
'
:
project
[
'
name
'
],
'
last_analysis_date
'
:
project
[
'
lastAnalysisDate
'
]
})
else
:
final_lis
t
.
append
({
list_ou
t
.
append
({
'
project_name
'
:
project
[
'
name
'
],
'
last_analysis_date
'
:
'
1970-01-01T01:00:00+0200
'
})
return
final_list
return
list_out
if
__name__
==
'
__main__
'
:
...
...
@@ -84,7 +85,6 @@ You can generate a token in SonarQube under My Account > Security
'''
)
os
.
sys
.
exit
(
1
)
# filter the data based on the last_analysis_date
final_list
=
fetch_data
()
filtered_list
=
filter_data
(
final_list
,
int
(
months
))
...
...
This diff is collapsed.
Click to expand it.
webapp/__init__.py
+
1
−
3
View file @
eba95fef
from
flask
import
Flask
from
config
import
Config
from
webapp
import
routes
# models
app
=
Flask
(
__name__
)
app
.
config
.
from_object
(
Config
)
from
webapp
import
routes
#, models
This diff is collapsed.
Click to expand it.
webapp/routes.py
+
6
−
6
View file @
eba95fef
...
...
@@ -8,13 +8,13 @@ from sq_projects_list import filter_data, fetch_data
import
config
conf
=
config
.
Config
()
@app.route
(
'
/
'
)
@app.route
(
'
/index
'
)
def
index
():
"""
Index page
"""
try
:
return
Response
(
json
.
dumps
(
filter_data
(
fetch_data
(
conf
.
INIT_LOCATION
),
12
)),
status
=
200
)
except
:
return
Response
(
'
Wea have a problem
'
,
status
=
500
)
return
filter_data
(
fetch_data
(),
12
)
return
Response
(
json
.
dumps
(
filter_data
(
fetch_data
(
conf
.
INIT_LOCATION
),
12
)),
status
=
200
)
except
Exception
as
err
:
return
Response
(
f
'
We have a problem:
{
err
}
'
,
status
=
500
)
return
filter_data
(
fetch_data
(),
12
)
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