Skip to content

Commit

Permalink
[AGENT-11701] Fix TeamCity Integration (#18041)
Browse files Browse the repository at this point in the history
* Handle project without builds

* Add changelog

* Refactor code

* Add comment

* Fix

* Update teamcity/changelog.d/18041.fixed

Co-authored-by: Ilia Kurenkov <ilia.kurenkov@datadoghq.com>

---------

Co-authored-by: Ilia Kurenkov <ilia.kurenkov@datadoghq.com>
  • Loading branch information
dkirov-dd and iliakur committed Jul 22, 2024
1 parent 70537a4 commit 5a568ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions teamcity/changelog.d/18041.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix handling of projects with no builds. We used to refresh all the projects whenever we encountered a build config that didn't have any builds associated with it. Now we refresh only the specific build config that's lacking builds.
14 changes: 9 additions & 5 deletions teamcity/datadog_checks/teamcity/teamcity_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,17 @@ def _collect_build_problems(self, new_build):
def _collect_new_builds(self, project_id):
last_build_id = self.bc_store.get_last_build_id(project_id, self.current_build_config)
if not last_build_id:
self._initialize()
# We want to handle the case of an unbuilt build config by checking for any last builds
self.log.debug(
'No builds for project %d and build config %d, checking again', project_id, self.current_build_config
)
ressource = "last_build"
options = {"project_id": project_id}
else:
self.log.debug('Checking for new builds...')
new_builds = get_response(
self, 'new_builds', build_conf=self.current_build_config, since_build=last_build_id
)
return new_builds
ressource = "new_builds"
options = {"since_build": last_build_id}
return get_response(self, ressource, build_conf=self.current_build_config, **options)

def _get_build_config_type(self, build_config):
if self.is_deployment:
Expand Down

0 comments on commit 5a568ed

Please sign in to comment.