Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[teamcity] Add ssl_validation flag to check #2091

Merged
merged 1 commit into from
Jan 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you forgot to pass the ssl_validation flag when calling _initialize_if_required

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jslatts The window for the 5.7 release will be closing soon. Do you have a moment to look at @remh 's feedback?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@irabinovitch sorry, missed the original notification. I added it in. Do you want me to rebase the PR against current master? I collapsed the fix into the original commit.

# 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 = _is_affirmative(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 off ssl certificate validation. Defaults to True.
# ssl_validation: false

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