jetbrains.buildServer.agent.AgentLifeCycleAdapter Java Examples
The following examples show how to use
jetbrains.buildServer.agent.AgentLifeCycleAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserUIDAndGIDImpl.java From TeamCity.Virtual with Apache License 2.0 | 6 votes |
public UserUIDAndGIDImpl(@NotNull final EventDispatcher<AgentLifeCycleListener> events) { events.addListener(new AgentLifeCycleAdapter(){ @Override public void afterAgentConfigurationLoaded(@NotNull final BuildAgent agent) { final BuildAgentConfiguration configuration = agent.getConfiguration(); if (configuration.getConfigurationParameters().get(VMConstants.DOCKER_PROPERTY) == null) return; if (!configuration.getSystemInfo().isUnix()) return; if (configuration.getSystemInfo().isWindows()) return; if (configuration.getSystemInfo().isMac()) return; detectSidAndGid(); } }); }
Example #2
Source File: SQMSBuildStartServiceFactory.java From TeamCity.SonarQubePlugin with Apache License 2.0 | 5 votes |
public SQMSBuildStartServiceFactory(@NotNull final SQMSBuildStartRunner sqmsBuildStartRunner, @NotNull final OSType osType, @NotNull final MonoLocator monoLocator, @NotNull final SQMSBuildFinishServiceFactory sqmsBuildFinishServiceFactory, @NotNull final EventDispatcher<AgentLifeCycleListener> dispatcher) { mySQMSBuildStartRunner = sqmsBuildStartRunner; myOSType = osType; myMonoLocator = monoLocator; mySqmsBuildFinishServiceFactory = sqmsBuildFinishServiceFactory; mySonarQubeMSBuildScannerLocator = new SonarQubeMSBuildScannerLocatorImpl(); dispatcher.addListener(new AgentLifeCycleAdapter() { @Override public void beforeRunnerStart(@NotNull final BuildRunnerContext runner) { if (runner.getRunType().equals(mySQMSBuildStartRunner.getType())) { mySqmsBuildFinishServiceFactory.setUpFinishStep(new SonarQubeMSBuildScannerLocator() { @Nullable @Override public String getExecutablePath(@NotNull final BuildRunnerContext runnerContext) throws RunBuildException { return mySonarQubeMSBuildScannerLocator.getExecutablePath(runner); } }, runner.getWorkingDirectory(), new SQRParametersAccessor(SQRParametersUtil.mergeAuthParameters(runner.getBuild().getSharedConfigParameters(), runner.getRunnerParameters()))); } } }); }
Example #3
Source File: KubeAgentConfigurationProvider.java From teamcity-kubernetes-plugin with Apache License 2.0 | 4 votes |
public KubeAgentConfigurationProvider(@NotNull EventDispatcher<AgentLifeCycleListener> agentEvents, @NotNull final BuildAgentConfigurationEx agentConfigurationEx) { LOG.info("Initializing Kube Provider..."); agentEvents.addListener(new AgentLifeCycleAdapter(){ @Override public void afterAgentConfigurationLoaded(@NotNull BuildAgent agent) { super.afterAgentConfigurationLoaded(agent); final Map<String, String> env = System.getenv(); final String providedServerUrl = env.get(KubeContainerEnvironment.SERVER_URL); if(StringUtil.isNotEmpty(providedServerUrl)) { LOG.info("Provided TeamCity Server URL: " + providedServerUrl); agentConfigurationEx.setServerUrl(providedServerUrl); } else { LOG.info("TeamCity Server URL was not provided. The instance wasn't started using TeamCity Kube integration."); return; } final String profileId = env.get(KubeContainerEnvironment.PROFILE_ID); if(StringUtil.isNotEmpty(profileId)){ LOG.info("Provided Profile Id: " + profileId); agentConfigurationEx.addConfigurationParameter(KubeContainerEnvironment.REQUIRED_PROFILE_ID_CONFIG_PARAM, profileId); } else { LOG.info("Profile Id was not provided. The instance wasn't started using TeamCity Kube integration."); return; } final String instanceName = env.get(KubeContainerEnvironment.INSTANCE_NAME); if (StringUtil.isNotEmpty(instanceName)) { LOG.info("Setting instance name to " + instanceName); agentConfigurationEx.setName(instanceName); } else { LOG.warn("Couldn't find 'env." + KubeContainerEnvironment.INSTANCE_NAME + "' property" ); } for (Map.Entry<String, String> entry : env.entrySet()){ final String key = entry.getKey(); final String value = entry.getValue(); if (key.startsWith(TEAMCITY_KUBERNETES_PROVIDED_PREFIX)){ LOG.info("prop( " + key + ") : " + value); agentConfigurationEx.addConfigurationParameter(key.substring(TEAMCITY_KUBERNETES_PROVIDED_PREFIX.length()), value); } } } }); }