diff --git a/src/Subscribers/EnsureTeamCityEnabled.php b/src/Subscribers/EnsureTeamCityEnabled.php index 0b9591d2..89793d31 100644 --- a/src/Subscribers/EnsureTeamCityEnabled.php +++ b/src/Subscribers/EnsureTeamCityEnabled.php @@ -15,15 +15,20 @@ use Symfony\Component\Console\Output\OutputInterface; /** * @internal */ -final readonly class EnsureTeamCityEnabled implements ConfiguredSubscriber +final class EnsureTeamCityEnabled implements ConfiguredSubscriber { + /** + * Indicates if the TeamCity logger has already been registered. + */ + private static bool $registered = false; + /** * Creates a new Configured Subscriber instance. */ public function __construct( - private InputInterface $input, - private OutputInterface $output, - private TestSuite $testSuite, + private readonly InputInterface $input, + private readonly OutputInterface $output, + private readonly TestSuite $testSuite, ) {} /** @@ -31,10 +36,16 @@ final readonly class EnsureTeamCityEnabled implements ConfiguredSubscriber */ public function notify(Configured $event): void { + if (self::$registered) { + return; + } + if (! $this->input->hasParameterOption('--teamcity')) { return; } + self::$registered = true; + $flowId = getenv('FLOW_ID'); $flowId = is_string($flowId) ? (int) $flowId : getmypid();