Class BuildServerImpl

    • Method Detail

      • setExecutorServiceManager

        public void setExecutorServiceManager​(@NotNull
                                              ExecutorServiceManager executorServiceManager)
      • setFlushQueueAction

        public void setFlushQueueAction​(@NotNull
                                        FlushQueueAction flushQueueAction)
      • getEntriesSince

        public List<SBuild> getEntriesSince​(@Nullable
                                            SBuild build,
                                            SBuildType buildType)
        Description copied from interface: SBuildServer
        Returns collection of finished and running builds which are later than the given one in term of changes. I.e. history builds which were started after the given one but relate to changes made before it, won't be returned. Collection is sorted by change order descending (recent first).
        Specified by:
        getEntriesSince in interface SBuildServer
        Parameters:
        build - the boundary build, the result collection won't include it. if null, all builds will be returned
        buildType - build configuration where to search in.
        Returns:
        collection of finished and running builds belonging to the specified configuration which start after the specified one (ordered by changes, recent first).
      • setDb

        public void setDb​(@NotNull
                          SQLRunnerEx db)
      • setPersonalBuildManagerEx

        public void setPersonalBuildManagerEx​(@NotNull
                                              PersonalBuildManagerEx personalBuildManager)
      • setFileWatcherFactory

        public void setFileWatcherFactory​(@NotNull
                                          FileWatcherFactory fileWatcherFactory)
      • initServer

        public void initServer()
      • setUserModelEx

        public void setUserModelEx​(UserModelEx userModel)
      • setBuildQueue

        public void setBuildQueue​(BuildQueueEx queue)
      • setRunTypeRegistry

        public void setRunTypeRegistry​(@NotNull
                                       RunTypeRegistry runTypeRegistry)
      • setVcsManagerEx

        public void setVcsManagerEx​(@NotNull
                                    VcsManagerEx vcsManager)
      • setProjectManagerImpl

        public void setProjectManagerImpl​(@NotNull
                                          ProjectManagerEx projectManager)
      • setLoginConfiguration

        public void setLoginConfiguration​(@NotNull
                                          LoginConfiguration loginConfiguration)
      • setResponsibilityFacade

        public void setResponsibilityFacade​(@NotNull
                                            ResponsibilityFacadeEx responsibilityFacade)
      • setBuildsManager

        public void setBuildsManager​(@NotNull
                                     BuildsManagerImpl buildsManager)
      • setProjectSettingsGeneratorRegistry

        public void setProjectSettingsGeneratorRegistry​(@NotNull
                                                        ProjectSettingsGeneratorRegistry projectSettingsGeneratorRegistry)
      • flushQueue

        public boolean flushQueue()
        Description copied from interface: SBuildServer
        Check for free build agents and try to send builds from queue to build agents.
        Specified by:
        flushQueue in interface SBuildServer
        Returns:
        true if at least one build was started
      • setTimeService

        public void setTimeService​(@NotNull
                                   TimeService timeService)
      • isShuttingDown

        public boolean isShuttingDown()
        Description copied from interface: BuildServerState
        Returns true if server shutdown is in progress.
        Specified by:
        isShuttingDown in interface BuildServerState
        Returns:
        see above
      • isDatabaseCreatedOnStartup

        public boolean isDatabaseCreatedOnStartup()
        Specified by:
        isDatabaseCreatedOnStartup in interface SBuildServer
        Returns:
        true if new database was created during server startup.
      • getRunningBuilds

        @NotNull
        public List<SRunningBuild> getRunningBuilds​(@Nullable
                                                    User user,
                                                    @NotNull
                                                    SBuildType buildType)
        Description copied from interface: RunningBuildsManager
        Returns all running builds including personal builds which belong to the specified build configuration. If user is not null then all non-personal builds and personal builds of this user will be returned. If user settings are configured to show all personal builds, then personal builds of other users will be returned as well. If user is null, then all personal and non-personal builds are returned. List of running builds is sorted by build id in reverse order (most recent build first).
        Specified by:
        getRunningBuilds in interface RunningBuildsManager
        Parameters:
        user - owner of personal builds or null
        buildType - build configuration
        Returns:
        see above
      • getRunningBuilds

        @NotNull
        public List<SRunningBuild> getRunningBuilds​(@Nullable
                                                    User user,
                                                    @Nullable
                                                    BuildDataFilter filter)
        Description copied from interface: RunningBuildsManager
        Returns all running builds including personal builds according to settings of the specified user. If user is not null then all non-personal builds and personal builds of this user will be returned. If user settings are configured to show all personal builds, then personal builds of other users will be returned as well. If user is null, then all personal and non-personal builds are returned. If filter is not null it will be applied to the result. List of running builds is sorted by build id in reverse order (most recent build first).
        Specified by:
        getRunningBuilds in interface RunningBuildsManager
        Parameters:
        user - owner of personal builds, can be null
        filter - filter to apply for builds, can be null
        Returns:
        unmodifiable list of running builds
      • getRunningStatus

        public Map<SBuildType,​List<SRunningBuild>> getRunningStatus​(@Nullable
                                                                          User user,
                                                                          @Nullable
                                                                          BuildDataFilter filter)
        Description copied from interface: RunningBuildsManager
        Returns map of running builds per build configuration. Method returns all personal builds if user is null, otherwise only personal builds of this user are returned. If filter is not null it will be applied to the result. The resulting map will contain only those build configurations for which list or running builds is not empty. List of running builds is sorted by build id in reverse order (most recent build first).
        Specified by:
        getRunningStatus in interface RunningBuildsManager
        Parameters:
        user - owner of personal builds, can be null
        filter - filter to apply for builds, can be null
        Returns:
        unmodifiable map of running builds per build type
      • setServerRootPath

        public void setServerRootPath​(String absolutePath)
      • fetchData

        public byte[] fetchData​(long userId,
                                long buildId,
                                String sourceId,
                                String value)
        Description copied from interface: BuildServer
        Get custom data provided by some data provider. Data providers are implementations of jetbrains.buildServer.serverSide.DataFetcher interfaces, which are registered on the server side using jetbrains.buildServer.serverSide.SBuildServer#registerExtension method.
        Specified by:
        fetchData in interface BuildServer
        Parameters:
        userId - Id of user who tries to fetch the data from the server.
        buildId - buildId parameter, which is passed to the fetchData method of DataFetcher interface implementation.
        sourceId - source identifier, which was used while DataFetcher registration using SBuildServer#registerExtension method.
        value - custom parameter, which is passed to the fetchData method of DataFetcher interface implementation.
        Returns:
        data, returned by the corresponding implementation of DataFetcher interface, if such DataFetcher was registered; empty array if no corresponding DataFetcher found.
      • getResponsibilityIds

        public List<String> getResponsibilityIds​(long userId)
        Description copied from interface: BuildServer
        Returns all configurations specified user is currently responsible for.
        Specified by:
        getResponsibilityIds in interface BuildServer
        Parameters:
        userId - TeamCity user unique identifier.
        Returns:
        list of configuration ids (buildTypeIds) the user is responsible for.
      • setRootUrl

        public void setRootUrl​(@NotNull
                               String url)
        Description copied from interface: RootUrlHolder
        Sets new root URL.
        Specified by:
        setRootUrl in interface RootUrlHolder
        Parameters:
        url - new root URL
      • isDefaultRootUrl

        public boolean isDefaultRootUrl()
      • setStatusProvider

        public void setStatusProvider​(@NotNull
                                      StatusProvider statusProvider)
      • getBuildNumber

        public String getBuildNumber()
        Description copied from interface: SBuildServer
        Returns server build number, i.e. build number of server-side code running on the build server
        Specified by:
        getBuildNumber in interface SBuildServer
        Returns:
        see above
      • getBuildDate

        public Date getBuildDate()
        Specified by:
        getBuildDate in interface SBuildServer
        Returns:
        date when the build was produced
      • getServerMajorVersion

        public final byte getServerMajorVersion()
        Description copied from interface: SBuildServer
        Get server major version, 3 for TeamCity 3.0
        Specified by:
        getServerMajorVersion in interface SBuildServer
        Returns:
        see above
      • getServerMinorVersion

        public final byte getServerMinorVersion()
        Description copied from interface: SBuildServer
        Get server minor version, 2 for TeamCity 1.2
        Specified by:
        getServerMinorVersion in interface SBuildServer
        Returns:
        see above
      • getFullServerVersion

        public String getFullServerVersion()
        Description copied from interface: SBuildServer
        Returns full server version string, including build number: TeamCity 3.0 EAP (build 4545)
        Specified by:
        getFullServerVersion in interface SBuildServer
        Returns:
        see above
      • getDaysToLicenseExpiration

        public int getDaysToLicenseExpiration()
        Description copied from interface: BuildServerEx
        Returns number of days till license expiration.
        Specified by:
        getDaysToLicenseExpiration in interface BuildServerEx
        Returns:
        -1 if there are no expirable license
        0 if license expired
        positive integer indicating number of days till license expiration.
      • getServerRootPath

        public String getServerRootPath()
        Description copied from interface: SBuildServer
        Path to server web application, i.e. servletContext.getRealPath("/")
        Specified by:
        getServerRootPath in interface SBuildServer
        Returns:
        see above
      • registerExtension

        public final <T extends TeamCityExtension> void registerExtension​(@NotNull
                                                                          Class<T> extensionClass,
                                                                          @NonNls @NotNull
                                                                          String sourceId,
                                                                          @NotNull
                                                                          T extension)
        Description copied from interface: ExtensionHolder
        Register an extension for some extension point.
        NOTE. TeamCity checks Spring beans for extensions as well
        Specified by:
        registerExtension in interface ExtensionHolder
        Parameters:
        extensionClass - class of the extension, which defines the extension point type
        sourceId - a unique Id for the given extension for given extension point
        extension - extension itself, implementation of the interface 'extensionClass'
      • unregisterExtension

        public final <T extends TeamCityExtension> void unregisterExtension​(@NotNull
                                                                            Class<T> extensionClass,
                                                                            @NonNls @NotNull
                                                                            String sourceId)
        Description copied from interface: ExtensionHolder
        Unregister an extension with given parameters registered for some extension point.
        Specified by:
        unregisterExtension in interface ExtensionHolder
        Parameters:
        extensionClass - class of the extension, which defines the extension point type
        sourceId - a unique Id for the given extension for given extension point
      • getExtensions

        @NotNull
        public final <T extends TeamCityExtensionCollection<T> getExtensions​(@NotNull
                                                                               Class<T> extensionClass)
        Description copied from interface: ExtensionsProvider
        Get list of extensions for some extension point. TeamCity checks all registered Spring beans for extensions
        Specified by:
        getExtensions in interface ExtensionsProvider
        Parameters:
        extensionClass - class of the extension, which defines the extension point type
        Returns:
        list of extensions for specified extension point
      • getExtension

        @Nullable
        public final <T extends TeamCityExtension> T getExtension​(@NotNull
                                                                  Class<T> extensionClass,
                                                                  @NotNull
                                                                  String sourceId)
        Description copied from interface: ExtensionsProvider
        Retrieves extension registered with specified type and id
        Specified by:
        getExtension in interface ExtensionsProvider
        Parameters:
        extensionClass - extension type
        sourceId - id
        Returns:
        extension or null
      • getStampedExtensionsSupplier

        @NotNull
        public <T extends TeamCityExtension,​CONTEXT,​TARGET> StampedExtensionsSupplier<CONTEXT,​TARGET> getStampedExtensionsSupplier​(@NotNull
                                                                                                                                                     Class<T> extensionClass,
                                                                                                                                                     @NotNull
                                                                                                                                                     Function<StampedExtensionsSupplier.StoredData<CONTEXT,​Collection<T>>,​TARGET> converter)
        Description copied from interface: ExtensionsProvider
        Live suppler of extensions. This supplier can be safely stored in a field of some class. It is updated automatically if a new extension of a given class is registered or if outer context was changed. For example this supplier is very useful if some internal property is used to select a single extension implementation which should be used:
         StampedExtensionsSupplier<String, MyExtension> supplier = extensionsProvider.getStampedExtensionsSupplier(MyExtension.class, extensions -> {
           for (MyExtension ext : extensions.data) {
             if (ext.getClass().getName().equals(extensions.context)) return ext;
           }
        
           return new DefaultMyExtension();
         });
        
         MyExtension currentlyUsedExtension = supplier.get(TeamCityProperties.getProperty("myextension.implementationClass"));
         
        here with each change of the "myextension.implementationClass" property the supplier will reset the internal cache and will call the provided function with the registered extensions collection and with the current context (the parameter value in this example). The internal cache is also reset automatically if the registered extensions collection changes. Without the getStampedExtensionsSupplier method, same code could be implemented with getExtensionsCollection(), but will require filtering the collection each time:
         ExtensionsCollection<MyExtension> allExtensions = extensionsProvider.getExtensionsCollection(MyExtension.class);
         MyExtension currentlyUsedExtension = null;
        
         for (MyExtension ext : allExtensions.getExtensions()) {
           if (ext.getClass().getName().equals(TeamCityProperties.getProperty("myextension.implementationClass"))) {
             currentlyUsedExtension = ext;
             break;
           }
         }
        
         if (currentlyUsedExtension == null) currentlyUsedExtension = new DefaultMyExtension()
         
        Specified by:
        getStampedExtensionsSupplier in interface ExtensionsProvider
        Parameters:
        extensionClass - extension class
        converter - function to convert the base extension. Will be automatically applied if underlying collection should be reset (eg if a new extension is registered).
        Returns:
        collection of extension
      • getSingletonService

        @NotNull
        public final <T> T getSingletonService​(@NotNull
                                               Class<T> serviceClass)
        Description copied from interface: ServiceLocator
        Searches for singleton service of specified type
        Specified by:
        getSingletonService in interface ServiceLocator
        Parameters:
        serviceClass - type of the service
        Returns:
        found service, never null
      • findSingletonService

        @Nullable
        public final <T> T findSingletonService​(@NotNull
                                                Class<T> serviceClass)
        Description copied from interface: ServiceLocator
        Searches for singleton service of specified type
        Specified by:
        findSingletonService in interface ServiceLocator
        Parameters:
        serviceClass - type of the service
        Returns:
        found service or null if there's no such service
      • getServices

        @NotNull
        public final <T> Collection<T> getServices​(@NotNull
                                                   Class<T> serviceClass)
        Description copied from interface: ServiceLocator
        Searches for all bean instances of type
        Specified by:
        getServices in interface ServiceLocator
        Parameters:
        serviceClass - - type to search
        Returns:
        collection of classes that implements T
      • findPreviousBuild

        @Nullable
        public SBuild findPreviousBuild​(@NotNull
                                        SBuild build)
        Description copied from interface: BuildsManager
        Finds a non personal build (running or finished) which was started before the specified build and contains same or previous changes than the specified build. The resulting build belongs to the same build configuration.
        Specified by:
        findPreviousBuild in interface BuildsManager
        Parameters:
        build - build to find previous build for
        Returns:
        previous build in same build configuration or null if there is no previous build
      • findBuildInstances

        public Collection<SBuild> findBuildInstances​(Collection<Long> buildIds)
        Description copied from interface: BuildsManager
        Returns collection of builds corresponding to the specified builds ids. Both running and finished builds can appear in the resulting collection. The collection will contain existing builds only. NOTE: RETURNED COLLECTION WILL NOT MAINTAIN REQUESTED ORDER!
        Specified by:
        findBuildInstances in interface BuildsManager
        Parameters:
        buildIds - build identifiers to be searched for.
        Returns:
        see above
      • findBuildInstanceByBuildNumber

        @Nullable
        public SBuild findBuildInstanceByBuildNumber​(@NotNull
                                                     String buildTypeId,
                                                     @NotNull
                                                     String buildNumber)
        Description copied from interface: BuildsManager
        Returns the most recent build (ordered by changes) with the specified build number
        Specified by:
        findBuildInstanceByBuildNumber in interface BuildsManager
        Parameters:
        buildTypeId - build configuration internal id
        buildNumber - build number string
        Returns:
        see above
      • findBuildInstancesByBuildNumber

        @NotNull
        public List<SBuild> findBuildInstancesByBuildNumber​(@NotNull
                                                            String buildTypeId,
                                                            @NotNull
                                                            String buildNumber)
        Description copied from interface: BuildsManager
        Returns builds in specified build configuration id having the specified build number. Builds are ordered by changes, i.e. the most recent build first. The list may contain personal builds too.
        Specified by:
        findBuildInstancesByBuildNumber in interface BuildsManager
        Parameters:
        buildTypeId - build configuration internal id
        buildNumber - build number
        Returns:
        see above