From a2f9c53f359fd7661641fd57408d8d5004bf5df9 Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Wed, 25 Jul 2018 10:28:09 +0200 Subject: [PATCH 1/3] Introduced Docker-base development environment --- Dockerfile | 11 +++++++++++ README.md | 6 ++++++ docker-compose.yml | 12 ++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8654362 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM alpine:3.8 + +# Installing required packages +RUN apk add --update --no-cache \ + python3 + +# Install dependencies +COPY requirements.txt /workspace/prometheus-jenkins-exporter/requirements.txt +RUN cd /workspace/prometheus-jenkins-exporter && pip3 install -r requirements.txt + +WORKDIR /workspace/prometheus-jenkins-exporter diff --git a/README.md b/README.md index 81ded15..42fc553 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,12 @@ jenkins_plugins_enabled_with_update_count ## Contributions +### Run the development environment + +``` +docker-compose build && docker-compose run dev sh +``` + ### Ensure the code is PEP 8 compliant `pycodestyle --max-line-length=180 prometheus_jenkins_exporter/*.py` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2808dd1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3" + +services: + dev: + build: + context: . + dockerfile: Dockerfile + command: [ "sh" ] + ports: + - 8000:8000 + volumes: + - /workspace/prometheus-jenkins-exporter:/workspace/prometheus-jenkins-exporter:delegated From 3cc420b635d8752dfa532d023b658505869e08b5 Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Wed, 25 Jul 2018 10:28:31 +0200 Subject: [PATCH 2/3] Added __pycache__/ to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 220f18d..8c7a7c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ dist MANIFEST prometheus_jenkins_exporter.egg-info +__pycache__/ From 24568299a6a75e4f154769eab059beaad0333ba8 Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Wed, 25 Jul 2018 10:29:23 +0200 Subject: [PATCH 3/3] Enabled faulthandler to dump stacktrace to stderr on segfault --- prometheus_jenkins_exporter/exporter.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/prometheus_jenkins_exporter/exporter.py b/prometheus_jenkins_exporter/exporter.py index 966f565..aca4110 100644 --- a/prometheus_jenkins_exporter/exporter.py +++ b/prometheus_jenkins_exporter/exporter.py @@ -4,6 +4,7 @@ import time import os import signal +import faulthandler from urllib.parse import urlencode, quote_plus from prometheus_client import start_http_server from prometheus_client.core import GaugeMetricFamily, REGISTRY @@ -11,6 +12,10 @@ from pythonjsonlogger import jsonlogger +# Enable dumps on stderr in case of segfault +faulthandler.enable() + + class JenkinsApiClient(): def __init__(self, config): self.config = config