jetbrains.buildServer.agent.BuildAgent Java Examples

The following examples show how to use jetbrains.buildServer.agent.BuildAgent. 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 vote down vote up
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: WinDbgToolsDetector.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
@Override
public void agentInitialized(@NotNull BuildAgent agent) {
  final BuildAgentConfiguration config = agent.getConfiguration();
  if (!config.getSystemInfo().isWindows()) return;
  LOG.info("Searching WinDbg installation...");

  LOG.info("Searching the WinDbg as part of Windows 10 SDK");
  File winDbgHomeDir = searchSDK8AndLater(WIN_DBG_10_ROOT_ENTRY_NAME, WIN_SDK_10_ROOT_ENTRY_NAME, "10");
  if(winDbgHomeDir == null){
    LOG.info("Searching the WinDbg as part of Windows 8.1 SDK");
    winDbgHomeDir = searchSDK8AndLater(WIN_DBG_81_ROOT_ENTRY_NAME, WIN_SDK_81_ROOT_ENTRY_NAME, "8.1");
    if(winDbgHomeDir == null) {
      LOG.info("Searching the WinDbg as part of Windows 8 SDK");
      winDbgHomeDir = searchSDK8AndLater(WIN_DBG_8_ROOT_ENTRY_NAME, WIN_SDK_8_ROOT_ENTRY_NAME, "8");
    } if(winDbgHomeDir == null) {
      LOG.info("Searching the WinDbg as part of Windows 7 SDK");
      winDbgHomeDir = searchSDK7x();
    }
  }

  if(winDbgHomeDir == null) LOG.info("WinDbg tools were not found on this machine.");
  else{
    final String winDbgHomeDirAbsolutePath = winDbgHomeDir.getAbsolutePath();
    LOG.info("WinDbg tools were found on path " + winDbgHomeDirAbsolutePath);
    config.addConfigurationParameter(WIN_DBG_PATH, winDbgHomeDirAbsolutePath);
  }
}
 
Example #3
Source File: KubeAgentConfigurationProvider.java    From teamcity-kubernetes-plugin with Apache License 2.0 4 votes vote down vote up
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);
                }
            }
        }
    });
}