Skip to content
This repository was archived by the owner on May 2, 2022. It is now read-only.

Commit bd5c1c5

Browse files
committed
Switched configuration to environment variables for easier integration with rancher.
Rancher has a nicer interface for configuring stuff with environment variables, swiching this image over to use it makes it easier to configure.
1 parent 719db9c commit bd5c1c5

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ RUN pip install --no-cache-dir -r requirements.txt
99
COPY jenkins_exporter.py /usr/src/app
1010

1111
EXPOSE 9118
12+
ENV JENKINS_SERVER=http://jenkins:8080 VIRTUAL_PORT=9118 DEBUG=0
1213

1314
ENTRYPOINT [ "python", "-u", "./jenkins_exporter.py" ]
14-
CMD ["-j", "http://jenkins:8080", "-p", "9118"]
15+
CMD []

jenkins_exporter.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
import argparse
77
from pprint import pprint
88

9+
import os
910
from sys import exit
1011
from prometheus_client import start_http_server
1112
from prometheus_client.core import GaugeMetricFamily, REGISTRY
1213

13-
DEBUG = 1
14+
DEBUG = int(os.environ.get('DEBUG', '0'))
1415

1516

1617
class JenkinsCollector(object):
@@ -144,15 +145,15 @@ def parse_args():
144145
metavar='jenkins',
145146
required=False,
146147
help='server url from the jenkins api',
147-
default='http://jenkins:8080'
148+
default=os.environ.get('JENKINS_SERVER', 'http://jenkins:8080')
148149
)
149150
parser.add_argument(
150151
'-p', '--port',
151152
metavar='port',
152153
required=False,
153154
type=int,
154155
help='Listen to this port',
155-
default=9118
156+
default=int(os.environ.get('VIRTUAL_PORT', '9118'))
156157
)
157158
return parser.parse_args()
158159

@@ -163,7 +164,7 @@ def main():
163164
port = int(args.port)
164165
REGISTRY.register(JenkinsCollector(args.jenkins))
165166
start_http_server(port)
166-
print "Serving at port: ", port
167+
print "Polling %s. Serving at port: %s" % (args.jenkins, port)
167168
while True:
168169
time.sleep(1)
169170
except KeyboardInterrupt:

0 commit comments

Comments
 (0)