Skip to content

Commit

Permalink
[teamcity] Add ssl_validation flag to check
Browse files Browse the repository at this point in the history
- Same as flag added for nginx in issue #1782
  • Loading branch information
Justin Slattery committed Dec 17, 2015
1 parent c210677 commit ad9b6d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 6 additions & 4 deletions checks.d/teamcity.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, name, init_config, agentConfig, instances=None):
# Keep track of last build IDs per instance
self.last_build_ids = {}

def _initialize_if_required(self, instance_name, server, build_conf):
def _initialize_if_required(self, instance_name, server, build_conf, ssl_validation):
# Already initialized
if instance_name in self.last_build_ids:
return
Expand All @@ -32,7 +32,7 @@ def _initialize_if_required(self, instance_name, server, build_conf):
build_conf=build_conf
)
try:
resp = requests.get(build_url, timeout=self.DEFAULT_TIMEOUT, headers=self.HEADERS)
resp = requests.get(build_url, timeout=self.DEFAULT_TIMEOUT, headers=self.HEADERS, verify=ssl_validation)
resp.raise_for_status()

last_build_id = resp.json().get('build')[0].get('id')
Expand Down Expand Up @@ -91,6 +91,8 @@ def check(self, instance):
if instance_name is None:
raise Exception("Each instance must have a unique name")

ssl_validation = instance.get('ssl_validation', True)

server = instance.get('server')
if 'server' is None:
raise Exception("Each instance must have a server")
Expand All @@ -103,7 +105,7 @@ def check(self, instance):
tags = instance.get('tags')
is_deployment = _is_affirmative(instance.get('is_deployment', False))

self._initialize_if_required(instance_name, server, build_conf)
self._initialize_if_required(instance_name, server, build_conf, ssl_validation)

# Look for new successful builds
new_build_url = self.NEW_BUILD_URL.format(
Expand All @@ -113,7 +115,7 @@ def check(self, instance):
)

try:
resp = requests.get(new_build_url, timeout=self.DEFAULT_TIMEOUT, headers=self.HEADERS)
resp = requests.get(new_build_url, timeout=self.DEFAULT_TIMEOUT, headers=self.HEADERS, verify=ssl_validation)
resp.raise_for_status()

new_builds = resp.json()
Expand Down
3 changes: 3 additions & 0 deletions conf.d/teamcity.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ instances:
# rather than just that a successful build happened
# is_deployment: true

# Optional, this turns of ssl ceritificate validation. Defaults to True.
# ssl_validation: false

# Optional, any additional tags you'd like to add to the event
# tags:
# - test
Expand Down

0 comments on commit ad9b6d3

Please sign in to comment.