Skip to content
Snippets Groups Projects
Commit 0b0a7de3 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

added service for fetching info about single jenkins job

parent c39e63e2
No related branches found
No related tags found
No related merge requests found
...@@ -6,5 +6,15 @@ ...@@ -6,5 +6,15 @@
"useSSL": false, "useSSL": false,
"keyfile": "", "keyfile": "",
"certfile": "" "certfile": ""
},
"pages": [
{
"type": "JenkinsSingleJob",
"hostname": "",
"user": "",
"password": "",
"jobName": "",
"fetchIntervalInSeconds": 60
} }
]
} }
\ No newline at end of file
...@@ -16,7 +16,7 @@ class CarrotCastleWebsite(FlaskBaseApp): ...@@ -16,7 +16,7 @@ class CarrotCastleWebsite(FlaskBaseApp):
super().__init__(appName, os.path.dirname(__file__), LOGGER, serveRobotsTxt=True) super().__init__(appName, os.path.dirname(__file__), LOGGER, serveRobotsTxt=True)
def _register_blueprints(self, app): def _register_blueprints(self, app):
app.register_blueprint(Routes.construct_blueprint()) app.register_blueprint(Routes.construct_blueprint(self._settings))
return app return app
......
from flask import Blueprint, render_template from flask import Blueprint, render_template
def construct_blueprint(): def construct_blueprint(settings):
routes = Blueprint('routes', __name__) routes = Blueprint('routes', __name__)
@routes.route('/', methods=['GET']) @routes.route('/', methods=['GET'])
......
import jenkins
class JenkinsService:
def __init__(self, server, username, password, view_name):
self.__jenkins = jenkins.Jenkins(url=server, username=username, password=password)
self.__view_name = view_name
def get_jobs(self):
return self.__jenkins.get_jobs(view_name=self.__view_name)
from typing import Dict
import jenkins
from TheCodeLabs_BaseUtils import CachedService
class JenkinsSingleJobService(CachedService):
def __init__(self, settings):
super().__init__(settings['fetchIntervalInSeconds'])
self._settings = settings
self._jenkins = jenkins.Jenkins(url=self._settings['hostname'],
username=self._settings['user'],
password=self._settings['password'])
def _fetch_data(self) -> Dict:
return self._jenkins.get_job_info(name=self._settings['jobName'])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment