Class SecuredBuildAgent

    • Method Detail

      • getAuthorizationToken

        @NotNull
        public String getAuthorizationToken()
        Description copied from interface: SBuildAgent
        Returns agent token which should be used to authorize build agent
        Specified by:
        getAuthorizationToken in interface SBuildAgent
        Returns:
        agent token which should be used to authorize build agent
      • upgrade

        public boolean upgrade​(Action<Boolean> callback)
        Description copied from interface: BuildAgentEx
        Sends upgrade command on agent
        Specified by:
        upgrade in interface BuildAgentEx
        Parameters:
        callback - will be called with true if upgrade was accepted by agent.
        Returns:
        true if upgrade is scheduled, false otherwise (for example if previous Upgrade call is still in progress).
      • setEnabled

        public void setEnabled​(boolean enabled,
                               @Nullable
                               SUser user,
                               @NotNull
                               String reason)
        Description copied from interface: SBuildAgent
        Changes this agent enabled status.
        Specified by:
        setEnabled in interface SBuildAgent
        Parameters:
        enabled - true if agent is enabled, and false otherwise
        user - user who changes the status or null
        reason - reason why the status is changed
      • setEnabled

        public void setEnabled​(boolean enabled,
                               @Nullable
                               SUser user,
                               @NotNull
                               String reason,
                               long statusRestoringTimestamp)
        Description copied from interface: SBuildAgent
        Changes this agent enabled status and restores it in the specified time.
        Specified by:
        setEnabled in interface SBuildAgent
        Parameters:
        enabled - true if agent is enabled, and false otherwise
        user - user who changes the status or null
        reason - reason why the status is changed
        statusRestoringTimestamp - timestamp at which agent status will be restored
      • setAuthorized

        public void setAuthorized​(boolean authorized,
                                  @Nullable
                                  SUser user,
                                  @NotNull
                                  String reason)
                           throws LicenseNotGrantedException
        Description copied from interface: SBuildAgent
        Changes this agent authorization status.
        Specified by:
        setAuthorized in interface SBuildAgent
        Parameters:
        authorized - true if agent should become authorized and false otherwise
        user - user who changes the status or null
        reason - reason why the status changed
        Throws:
        LicenseNotGrantedException - if agent cannot be authorized because there is not enough license tokens
      • isLocal

        public void isLocal​(Action<Boolean> callback)
        Description copied from interface: BuildAgentEx
        Calls callback with true if this agent is local for sure (i.e. installed on the same machine as server).
        Specified by:
        isLocal in interface BuildAgentEx
      • releaseSources

        public void releaseSources()
        Description copied from interface: SBuildAgent
        Releases sources of all of the build configurations ever built on this agent, after that a full checkout will be performed for all of these configurations on this agent.
        Specified by:
        releaseSources in interface SBuildAgent
      • releaseSources

        public void releaseSources​(@NotNull
                                   SBuildType buildType)
        Description copied from interface: SBuildAgent
        Releases sources of the specified build configuration on this agent. A full checkout will be performed when a build of this build configuration is started on this agent.
        Specified by:
        releaseSources in interface SBuildAgent
        Parameters:
        buildType - build configuration
      • getAgentStatusToRestore

        @Nullable
        public Boolean getAgentStatusToRestore()
        Description copied from interface: SBuildAgent
        Returns null if agent status will not be restored, otherwise returns status to restore
        Specified by:
        getAgentStatusToRestore in interface SBuildAgent
        Returns:
        null if agent status will not be restored, otherwise returns status to restore
      • getAgentStatusRestoringTimestamp

        @Nullable
        public Date getAgentStatusRestoringTimestamp()
        Description copied from interface: SBuildAgent
        Returns null if agent status will not be restored, otherwise returns status restoring timestamp
        Specified by:
        getAgentStatusRestoringTimestamp in interface SBuildAgent
        Returns:
        null if agent status will not be restored, otherwise returns status restoring timestamp
      • getBuildHistory

        @NotNull
        public List<SFinishedBuild> getBuildHistory​(@Nullable
                                                    User user,
                                                    boolean includeCanceled)
        Description copied from interface: AgentBuildHistory
        Returns the build history of this agent.

        The history can be filtered by user, as well as by cancelled builds.

        Specified by:
        getBuildHistory in interface AgentBuildHistory
        Parameters:
        user - if set the result will contain only builds by user
        includeCanceled - if set the result will include canceled builds as well
        Returns:
        build history
      • getIdleTime

        public long getIdleTime()
        Specified by:
        getIdleTime in interface SBuildAgent
        Returns:
        number of milliseconds build agent was idle. If there was no build started time since registration is returned. If agent is running a build, 0 is returned.
      • getCpuCount

        public int getCpuCount()
        Description copied from interface: BuildAgent
        Returns the number of CPUs of this agent
        Specified by:
        getCpuCount in interface AgentDescription
        Specified by:
        getCpuCount in interface BuildAgent
        Returns:
        number of CPUs or -1 if count is not available
      • getAgentPoolId

        public int getAgentPoolId()
        Description copied from interface: BuildAgent

        Returns the pool id the agent belongs to.

        Specified by:
        getAgentPoolId in interface BuildAgent
        Returns:
        agent pool id the agent belongs to
      • setUpgrading

        public void setUpgrading​(boolean isUpgrading)
        Description copied from interface: BuildAgentEx
        Changes agent upgrading status. Note that this method does not initiate upgrade. To initiate upgrade use BuildAgentEx.upgrade(Action) method.
        Specified by:
        setUpgrading in interface BuildAgentEx
        Parameters:
        isUpgrading - agent upgrade status
      • register

        public void register()
        Description copied from interface: BuildAgentEx
        Makes this agent registered.
        Specified by:
        register in interface BuildAgentEx
      • unregister

        public void unregister​(@NotNull
                               String unregistrationReason)
        Description copied from interface: BuildAgentEx
        Makes this agent unregistered.
        Specified by:
        unregister in interface BuildAgentEx
        Parameters:
        unregistrationReason - reason of the agent unregistration
      • setCommunicationTimestamp

        public void setCommunicationTimestamp​(Date timestamp)
        Description copied from interface: BuildAgentEx
        Updates agent - server binding timestamp and persists it in database if current node is allowed to do that
        Specified by:
        setCommunicationTimestamp in interface BuildAgentEx
        Parameters:
        timestamp - timestamp
      • updateCommunicationTimestampInMemory

        public void updateCommunicationTimestampInMemory​(@NotNull
                                                         Date timestamp)
        Description copied from interface: BuildAgentEx
        Updates agent - server binding timestamp in memory, does not persists it in database
        Specified by:
        updateCommunicationTimestampInMemory in interface BuildAgentEx
      • getAgentTypeId

        public int getAgentTypeId()
        Description copied from interface: SBuildAgent
        Returns id of this agent type. All non cloud agents have own agent type. Cloud agents can share the same agent type. For cloud agents, agent type is the same as image.
        Specified by:
        getAgentTypeId in interface SBuildAgent
        Returns:
        agent type id.
      • getVersion

        @NotNull
        public String getVersion()
        Description copied from interface: SBuildAgent
        Returns agent version.
        Specified by:
        getVersion in interface SBuildAgent
        Returns:
        agent version
      • getPluginsSignature

        @NotNull
        public String getPluginsSignature()
        Description copied from interface: SBuildAgent
        Returns signature of plugins installed on the agent. The agent version and plugins signature are used to determine whether upgrade of this agent is required or not.
        Specified by:
        getPluginsSignature in interface SBuildAgent
        Returns:
        signature of plugins installed on the agent.
      • isOutdated

        public boolean isOutdated()
        Description copied from interface: SBuildAgent
        Returns true if version of this agent does not match version of the server.
        Specified by:
        isOutdated in interface SBuildAgent
        Returns:
        see above
      • isPluginsOutdated

        public boolean isPluginsOutdated()
        Description copied from interface: SBuildAgent
        Returns true if some of the agent plugins are outdated.
        Specified by:
        isPluginsOutdated in interface SBuildAgent
        Returns:
        see above
      • getOperatingSystemName

        @NotNull
        public String getOperatingSystemName()
        Description copied from interface: AgentDescription
        Returns name of the operating system where the agent is currently running.
        Specified by:
        getOperatingSystemName in interface AgentDescription
        Returns:
        name of the operating system where the agent is currently running.
      • getAvailableParameters

        @NotNull
        public Map<String,​String> getAvailableParameters()
        Description copied from interface: AgentDescription
        Returns map of parameters available on the agent. These parameters include environment variables defined for the agent process as well as parameters defined in the agent configuration file.
        Specified by:
        getAvailableParameters in interface AgentDescription
        Returns:
        see above
      • getAvailableParameterValue

        @Nullable
        public String getAvailableParameterValue​(@NotNull
                                                 String parameterName)
        Description copied from interface: AgentDescription
        Returns value of a single available parameter. This is equivalent to {@link #getAvailableParameters().get(name)} but can work faster.
        Specified by:
        getAvailableParameterValue in interface AgentDescription
        Parameters:
        parameterName - name of the parameter
        Returns:
        see above
      • isCaseInsensitiveEnvironment

        public boolean isCaseInsensitiveEnvironment()
        Specified by:
        isCaseInsensitiveEnvironment in interface AgentDescription
        Returns:
        true if names of environment variables are case insensitive
      • getConfigurationParameters

        @NotNull
        public Map<String,​String> getConfigurationParameters()
        Description copied from interface: AgentDescription
        Returns map of configuration parameters that are defined on the build agent. Those parameters may be defined in agent configuration files or may be provided by agent plugins.
        Specified by:
        getConfigurationParameters in interface AgentDescription
        Returns:
        map of parameters
      • stopBuild

        public boolean stopBuild​(@NotNull
                                 SRunningBuild build)
        Description copied from interface: BuildAgentEx
        Sends stop build command to agent.
        Specified by:
        stopBuild in interface BuildAgentEx
        Returns:
        true if build was stopped on agent and false otherwise
      • getRemoteInterface

        public <T> T getRemoteInterface​(@NotNull
                                        Class<T> type)
        Description copied from interface: BuildAgentEx
        Extension point allowing to call custom methods on agent remotely.
        Specified by:
        getRemoteInterface in interface BuildAgentEx
        Parameters:
        type - should contain only simple methods - with simple parameters and return types (number and strings)
      • updateAgent

        public void updateAgent()
        Description copied from interface: BuildAgentEx
        Assuming that some other node can change agent information in database, this method reloads agent fields from database.
        Specified by:
        updateAgent in interface BuildAgentEx
      • isFakeAgent

        public boolean isFakeAgent()
        Description copied from interface: BuildAgentEx
        Usually running builds have some agent, but sometimes this is not the case (composite build). To avoid returning null in such cases and make other code work properly a fake agent is created.
        Specified by:
        isFakeAgent in interface BuildAgentEx
        Returns:
        true if this agent is a fake, not real agent.
      • trySetSpecialState

        public boolean trySetSpecialState​(BuildAgentSpecialState specialState)
        Description copied from interface: BuildAgentEx
        Tries atomically to set a certain special state on agent. This operation is thread-safe
        Specified by:
        trySetSpecialState in interface BuildAgentEx
        Returns:
        boolean if successful, false otherwise
      • getCurrentAgentVersion

        @NotNull
        public String getCurrentAgentVersion()
        Specified by:
        getCurrentAgentVersion in interface BuildAgentEx
        Returns:
        current agent version, i.e. version which corresponds to a fully updated agent
      • getCurrentAgentPluginsSignature

        @NotNull
        public String getCurrentAgentPluginsSignature()
        Specified by:
        getCurrentAgentPluginsSignature in interface BuildAgentEx
        Returns:
        current plugins signature, i.e. a signature which corresponds to a fully updated agent
      • isCloudAgent

        public boolean isCloudAgent()
        Specified by:
        isCloudAgent in interface SBuildAgent
        Returns:
        true if this agent is started by TeamCity cloud integration
      • canStartBuildIfAgentOutdated

        public boolean canStartBuildIfAgentOutdated()
        Specified by:
        canStartBuildIfAgentOutdated in interface SBuildAgent
        Returns:
        true if agent can start builds even if the agent is outdated
      • getCommunicationProtocolDescription

        @NotNull
        public String getCommunicationProtocolDescription()
        Description copied from interface: SBuildAgent
        Returns short description of the protocol that is used to communicate with this agent.
        Examples: "unidirectional", "local".
        Specified by:
        getCommunicationProtocolDescription in interface SBuildAgent
      • getRunningBuild

        @Nullable
        public SRunningBuild getRunningBuild()
        Description copied from interface: SBuildAgent
        Returns the build which is currently running on the agent; null if no such build available
        Specified by:
        getRunningBuild in interface SBuildAgent
        Returns:
        the build which is currently running on the agent; null if no such build available
      • getHostName

        public String getHostName()
        Description copied from interface: SBuildAgent
        Returns hostname of the computer where build agent is running. If server is unable to resolve agent address to host name the address is returned.
        Specified by:
        getHostName in interface SBuildAgent
        Returns:
        Returns hostname of the computer where build agent is running
      • getHostAddress

        public String getHostAddress()
        Description copied from interface: SBuildAgent
        Returns IP address or fully qualified domain name (depending on the ownAddress property in the buildAgent.properties) of the computer where build agent is running
        Specified by:
        getHostAddress in interface SBuildAgent
        Returns:
        see above
      • getPort

        public int getPort()
        Description copied from interface: SBuildAgent
        Port where agent is listening for server commands.
        Specified by:
        getPort in interface SBuildAgent
        Returns:
        see above
      • ping

        public boolean ping()
        Description copied from interface: SBuildAgent
        Try to ping agent over networks
        Specified by:
        ping in interface SBuildAgent
        Returns:
        true if agent is reachable
      • getId

        public int getId()
        Description copied from interface: BuildAgent
        Returns this agent unique id
        Specified by:
        getId in interface BuildAgent
        Returns:
        agent unique id
      • getName

        public String getName()
        Description copied from interface: BuildAgent
        Returns name of the agent
        Specified by:
        getName in interface BuildAgent
        Returns:
        name of the agent
      • setName

        public void setName​(@NotNull
                            String name)
        Description copied from interface: BuildAgentInit
        Sets new name to the agent.
        Specified by:
        setName in interface BuildAgentInit
        Parameters:
        name - new name for an agent
      • setAgentTypeId

        public void setAgentTypeId​(int agentTypeId)
        Description copied from interface: BuildAgentInit
        Set agent type id to the instance of the agent.
        Specified by:
        setAgentTypeId in interface BuildAgentInit
        Parameters:
        agentTypeId - new type id.
      • initEnabled

        public void initEnabled​(boolean enabled)
        Description copied from interface: BuildAgentInit
        Initializes enabled status in agent
        Specified by:
        initEnabled in interface BuildAgentInit
        Parameters:
        enabled - true if agent is enabled
      • initAuthorized

        public void initAuthorized​(boolean authorized)
        Description copied from interface: BuildAgentInit
        Initializes authorized status in agent
        Specified by:
        initAuthorized in interface BuildAgentInit
      • isUpgrading

        public boolean isUpgrading()
        Description copied from interface: BuildAgent
        Returns true if agent is upgrading
        Specified by:
        isUpgrading in interface BuildAgent
        Returns:
        true if agent is upgrading
      • isRegistered

        public boolean isRegistered()
        Description copied from interface: SBuildAgent
        Returns true or false depending on whether this agent is currently registered on server or not.
        Specified by:
        isRegistered in interface SBuildAgent
        Returns:
        see above
      • getUnregistrationComment

        @Nullable
        public String getUnregistrationComment()
        Description copied from interface: SBuildAgent
        If agent is not registered returns reason of its' unregistration.
        Specified by:
        getUnregistrationComment in interface SBuildAgent
        Returns:
        agent is not registered returns reason of its' unregistration.
      • getRegistrationTimestamp

        @NotNull
        public Date getRegistrationTimestamp()
        Description copied from interface: SBuildAgent
        Returns timestamp of this agent registration. If agent is not registered the returned timestamp is timestamp of last agent registration.
        Specified by:
        getRegistrationTimestamp in interface SBuildAgent
        Returns:
        see above
      • getLastCommunicationTimestamp

        public Date getLastCommunicationTimestamp()
        Description copied from interface: SBuildAgent
        Returns timestamp of the last agent - server (or server - agent) successful communication.
        Specified by:
        getLastCommunicationTimestamp in interface SBuildAgent
        Returns:
        see above
      • restoreAgent

        public boolean restoreAgent()
        Description copied from interface: BuildAgentInit
        Restores this agent data from the database.
        Specified by:
        restoreAgent in interface BuildAgentInit
        Returns:
        true if agent was in the database and its status was restored and false if this agent is new
      • generateUniqueAgentAuthorizationToken

        public void generateUniqueAgentAuthorizationToken()
        Description copied from interface: BuildAgentInit
        Generates new agent authorization token for this agent. It is guaranteed that the new authorization token is unique among the all agents in the database.
        Specified by:
        generateUniqueAgentAuthorizationToken in interface BuildAgentInit
      • describe

        @NotNull
        public String describe​(boolean verbose)
        Specified by:
        describe in interface Loggable
        Specified by:
        describe in interface SBuildAgent
        Parameters:
        verbose - verbosity of object description
        Returns:
        description of this object. If verbose is true, description should have mode details.
      • isAccessible

        public boolean isAccessible()
        Description copied from interface: BuildAgentEx
        Returns true if the agent is connected to the current node, otherwise returns false. For example on the read-only node always return false. The remote operations can be executed on the agent only if the method returns true.
        Specified by:
        isAccessible in interface BuildAgentEx
      • getLastFinishedBuildDateOnAgent

        @Nullable
        public Date getLastFinishedBuildDateOnAgent​(Date finishTimeAfter)
        Description copied from interface: BuildAgentEx
        Returns date of last finished build since given time
        Specified by:
        getLastFinishedBuildDateOnAgent in interface BuildAgentEx
        Parameters:
        finishTimeAfter - finish time lower bound
        Returns:
      • isRemoved

        public boolean isRemoved()
        Specified by:
        isRemoved in interface BuildAgentEx
        Returns:
        true if this agent is removed
      • getParameterValue

        public String getParameterValue​(@NotNull
                                        String paramName)
        Description copied from interface: BuildAgentEx
        Returns value of a parameter with a given name. This method can access all agent parameters, including those which should not be exposed in the UI. The method can only be called by an authority with system admin like permission.
        Specified by:
        getParameterValue in interface BuildAgentEx
        Parameters:
        paramName - parameter name
        Returns:
        see above