diff --git a/teamcity/changelog.d/18041.fixed b/teamcity/changelog.d/18041.fixed new file mode 100644 index 0000000000000..3b855bf6230ee --- /dev/null +++ b/teamcity/changelog.d/18041.fixed @@ -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. diff --git a/teamcity/datadog_checks/teamcity/teamcity_rest.py b/teamcity/datadog_checks/teamcity/teamcity_rest.py index e907a68ee4218..9f7b727a6b230 100644 --- a/teamcity/datadog_checks/teamcity/teamcity_rest.py +++ b/teamcity/datadog_checks/teamcity/teamcity_rest.py @@ -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: