Class BuildAgentConfigurationImpl
- java.lang.Object
-
- jetbrains.buildServer.agent.impl.config.BuildAgentConfigurationImpl
-
- All Implemented Interfaces:
AgentConfiguration
,BuildAgentConfiguration
,BuildAgentConfigurationEx
,InternalPropertiesHolder
public class BuildAgentConfigurationImpl extends Object implements BuildAgentConfigurationEx, AgentConfiguration
- Author:
- Kir
-
-
Field Summary
Fields Modifier and Type Field Description static int
OWN_PORT
-
Constructor Summary
Constructors Constructor Description BuildAgentConfigurationImpl(BuildAgentSystemInfo systemInfo, BuildParametersMapsFactory mapsFactory, AgentUnresolvedParametersFactory parametersFactory, BuildAgentConfigurablePaths paths, BuildAgentConfigurationWellKnownAgentProperties wellknown, BuildAgentConfigurationInitializer initializer, BuildAgentConfigurationPersister persister, BuildAgentConfigurationImplicitParameters parameters, AgentOperationModeHolder agentOperationModeHolder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAlternativeAgentAddress(String address)
Adds alternative agent address that may be used by the server to communicate with agent.void
addConfigurationParameter(String name, String value)
Adds all-builds wide configuration parameter.void
addCustomProperty(String name, String value)
Adds new custom property to the configurationvoid
addEnvironmentVariable(String key, String value)
Adds all-builds wide environment variable.void
addSystemProperty(String key, String value)
Adds all-builds wide system property.File
getAgentConfDirectory()
AgentContextEx
getAgentContext()
File
getAgentHomeDirectory()
File
getAgentInfoFile()
File
getAgentLibDirectory()
File
getAgentLogsDirectory()
Returns directory containing agent log filesFile
getAgentPluginsDirectory()
File
getAgentPluginsUnpackingInfoFile()
File
getAgentTempDirectory()
Returns path to a folder underBuildAgentConfiguration.getTempDirectory()
.File
getAgentToolsDirectory()
Provides path to tools folder on build agent.File
getAgentUpdateDirectory()
File
getAgentUpgradeFiltersFile()
String
getAgentZipName()
Collection<String>
getAlternativeAddresses()
String
getAuthorizationToken()
Returns agent authorization token which should be used to authorize build agentBuildParametersMap
getBuildParameters()
Returns build parameters.File
getBuildTempDirectory()
Returns path to a folder underBuildAgentConfiguration.getTempDirectory()
.File
getCacheDirectory()
Returns path to a folder underBuildAgentConfiguration.getTempDirectory()
Temp directory for build agent instance is set to that folder.File
getCacheDirectory(String key)
Returns path to a folder under agent's system directory by a key.Map<String,String>
getConfigurationParameters()
Returns configuration parameters of this buildMap<String,String>
getCustomProperties()
Returns map of custom properties (defined in buildAgent.properties file and added by extensions).String
getInternalProperty(String name, String def)
String
getName()
Returns name of the agentAgentOperationMode
getOperationMode()
Returns agent's current operation mode.String
getOwnAddress()
Returns IP address where agent accepts commands from the serverint
getOwnPort()
Returns port where agent accepts commands from the serverValueResolver
getParametersResolver()
Creates value resolver for parameters resolution in strings.String
getPingCode()
Returns the code to be returned from the ping methodFile
getPropertiesFile()
int
getServerConnectionTimeout()
Returns connection timeout in seconds.SimpleCredentials
getServerProxyCredentials()
String
getServerProxyHost()
int
getServerProxyPort()
String
getServerUrl()
Returns server URLFile
getSystemDirectory()
Returns path to a folder containing all system caches.BuildAgentSystemInfo
getSystemInfo()
Returns agent jvm(system) informationFile
getTempDirectory()
Returns path to temp directory: parent folder of agent temp directory and build temp directory By default it returns INSTALL_DIR/temp, but that may be changes in buildAgent.properties file.String
getUpdateContentsXmlName()
String
getUpdatePluginsBasePath()
File
getVcsCheckoutdirStateFile(File checkoutDir)
File[]
getVcsCheckoutdirStateFiles()
File
getWorkDirectory()
Returns path to AGENT_INSTALL_DIR/work directoryvoid
initFrom(File propertiesFile)
Loads configuration from the properties fileboolean
isAgentUpgradeWithoutRestartAllowed()
boolean
isLoadingToolsOnDemandAllowing()
boolean
isToolsRemovalWithoutRestartAllowed()
boolean
isUpgradeDisabled()
Checks for system property that disables build agent upgradeboolean
removeConfigurationParameter(String name)
Remove build agent configuration parameter added via @code(addConfigurationParameter) method.void
setAuthorizationToken(String token)
Changes agent authorization tokenvoid
setName(String name)
Changes agent namevoid
setOwnPort(int ownPort)
Changes agent portvoid
setServerUrl(String serverUrl)
Sets new server URLvoid
setTempDir(String pathToTempDir)
Sets new path to temp directoryvoid
setWorkDir(String pathToWorkDir)
Sets new path to work directoryboolean
shouldSkipPluginsHashCheck()
void
updateConfiguration(AgentRegistrationDetails details)
Updates configuration to reflect changes from AgentRegistrationDetailsvoid
validateParameters()
Validated build agent configuration.
-
-
-
Field Detail
-
OWN_PORT
public static final int OWN_PORT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BuildAgentConfigurationImpl
public BuildAgentConfigurationImpl(@NotNull BuildAgentSystemInfo systemInfo, @NotNull BuildParametersMapsFactory mapsFactory, @NotNull AgentUnresolvedParametersFactory parametersFactory, @NotNull BuildAgentConfigurablePaths paths, @NotNull BuildAgentConfigurationWellKnownAgentProperties wellknown, @NotNull BuildAgentConfigurationInitializer initializer, @NotNull BuildAgentConfigurationPersister persister, @NotNull BuildAgentConfigurationImplicitParameters parameters, @NotNull AgentOperationModeHolder agentOperationModeHolder)
-
-
Method Detail
-
getCustomProperties
@NotNull public Map<String,String> getCustomProperties()
Description copied from interface:BuildAgentConfiguration
Returns map of custom properties (defined in buildAgent.properties file and added by extensions). The property names are normally prefixed with env. and system.- Specified by:
getCustomProperties
in interfaceBuildAgentConfiguration
- Returns:
- map of custom properties
-
getConfigurationParameters
@NotNull public Map<String,String> getConfigurationParameters()
Description copied from interface:BuildAgentConfiguration
Returns configuration parameters of this build- Specified by:
getConfigurationParameters
in interfaceBuildAgentConfiguration
- Returns:
- unmodifiable configuration parameters map
-
getParametersResolver
@NotNull public ValueResolver getParametersResolver()
Description copied from interface:BuildAgentConfiguration
Creates value resolver for parameters resolution in strings. The resolution rules are the same as for build parameters- Specified by:
getParametersResolver
in interfaceBuildAgentConfiguration
- Returns:
- value resolver to perform resolution of all parameters references within string
-
getOperationMode
@NotNull public AgentOperationMode getOperationMode()
Description copied from interface:BuildAgentConfiguration
Returns agent's current operation mode. SeeAgentOperationMode
- Specified by:
getOperationMode
in interfaceBuildAgentConfiguration
- Returns:
-
setWorkDir
public void setWorkDir(@NotNull String pathToWorkDir)
Description copied from interface:BuildAgentConfigurationEx
Sets new path to work directory- Specified by:
setWorkDir
in interfaceBuildAgentConfigurationEx
- Parameters:
pathToWorkDir
- new path to work directory
-
getAuthorizationToken
@NotNull public String getAuthorizationToken()
Description copied from interface:BuildAgentConfiguration
Returns agent authorization token which should be used to authorize build agent- Specified by:
getAuthorizationToken
in interfaceBuildAgentConfiguration
- Returns:
- agent authorization token which should be used to authorize build agent
-
getPingCode
@NotNull public String getPingCode()
Description copied from interface:BuildAgentConfiguration
Returns the code to be returned from the ping method- Specified by:
getPingCode
in interfaceBuildAgentConfiguration
- Returns:
- see above
-
updateConfiguration
public void updateConfiguration(@NotNull AgentRegistrationDetails details)
Description copied from interface:BuildAgentConfigurationEx
Updates configuration to reflect changes from AgentRegistrationDetails- Specified by:
updateConfiguration
in interfaceBuildAgentConfigurationEx
- Parameters:
details
- server data
-
getInternalProperty
@Nullable public String getInternalProperty(@NotNull String name, String def)
- Specified by:
getInternalProperty
in interfaceInternalPropertiesHolder
-
isUpgradeDisabled
public boolean isUpgradeDisabled()
Description copied from interface:BuildAgentConfigurationEx
Checks for system property that disables build agent upgrade- Specified by:
isUpgradeDisabled
in interfaceBuildAgentConfigurationEx
- Returns:
- true if upgrade is disabled
-
getServerConnectionTimeout
public int getServerConnectionTimeout()
Description copied from interface:BuildAgentConfiguration
Returns connection timeout in seconds. This timeout should be specified to all HTTP connections to the server.- Specified by:
getServerConnectionTimeout
in interfaceAgentConfiguration
- Specified by:
getServerConnectionTimeout
in interfaceBuildAgentConfiguration
- Returns:
- see above.
-
addAlternativeAgentAddress
public void addAlternativeAgentAddress(@NotNull String address)
Description copied from interface:BuildAgentConfiguration
Adds alternative agent address that may be used by the server to communicate with agent.- Specified by:
addAlternativeAgentAddress
in interfaceBuildAgentConfiguration
- Parameters:
address
- ip address
-
getAlternativeAddresses
@NotNull public Collection<String> getAlternativeAddresses()
- Specified by:
getAlternativeAddresses
in interfaceBuildAgentConfigurationEx
- Returns:
- a list of plugin provided own addresses.
-
getAgentContext
@NotNull public AgentContextEx getAgentContext()
- Specified by:
getAgentContext
in interfaceBuildAgentConfigurationEx
- Returns:
- agent parameters context
-
getAgentInfoFile
@NotNull public File getAgentInfoFile()
- Specified by:
getAgentInfoFile
in interfaceAgentConfiguration
- Specified by:
getAgentInfoFile
in interfaceBuildAgentConfigurationEx
- Returns:
- teamcity-agent.xml file path
-
getAgentPluginsUnpackingInfoFile
@NotNull public File getAgentPluginsUnpackingInfoFile()
- Specified by:
getAgentPluginsUnpackingInfoFile
in interfaceAgentConfiguration
- Specified by:
getAgentPluginsUnpackingInfoFile
in interfaceBuildAgentConfigurationEx
- Returns:
- file where agent manager stores information about unpacked plugins location
-
getAgentUpgradeFiltersFile
@NotNull public File getAgentUpgradeFiltersFile()
- Specified by:
getAgentUpgradeFiltersFile
in interfaceAgentConfiguration
- Specified by:
getAgentUpgradeFiltersFile
in interfaceBuildAgentConfigurationEx
- Returns:
- path to a file that accepts agent upgrade configuration
-
getVcsCheckoutdirStateFile
@NotNull public File getVcsCheckoutdirStateFile(@NotNull File checkoutDir)
- Specified by:
getVcsCheckoutdirStateFile
in interfaceBuildAgentConfigurationEx
- Returns:
- xml file containing vcs revision information for provided directory (must be checkout directory of one or more configurations).
-
getVcsCheckoutdirStateFiles
@NotNull public File[] getVcsCheckoutdirStateFiles()
- Specified by:
getVcsCheckoutdirStateFiles
in interfaceBuildAgentConfigurationEx
- Returns:
- array of xml files with vcs revision informations available on current agent
-
validateParameters
public void validateParameters() throws BuildAgentStartFailedException
Description copied from interface:BuildAgentConfigurationEx
Validated build agent configuration.- Specified by:
validateParameters
in interfaceBuildAgentConfigurationEx
- Throws:
BuildAgentStartFailedException
- if validation is failed
-
getServerProxyHost
@Nullable public String getServerProxyHost()
- Specified by:
getServerProxyHost
in interfaceAgentConfiguration
- Specified by:
getServerProxyHost
in interfaceBuildAgentConfigurationEx
- Returns:
- proxy host that should be used for connections to TeamCity Server, or null of no proxy should be used
-
getServerProxyPort
public int getServerProxyPort()
- Specified by:
getServerProxyPort
in interfaceAgentConfiguration
- Specified by:
getServerProxyPort
in interfaceBuildAgentConfigurationEx
- Returns:
- proxy port that should be used for connections to TeamCity Server, or -1 if default port should be used.
- See Also:
BuildAgentConfigurationEx.getServerProxyHost()
-
getServerProxyCredentials
@Nullable public SimpleCredentials getServerProxyCredentials()
- Specified by:
getServerProxyCredentials
in interfaceAgentConfiguration
- Specified by:
getServerProxyCredentials
in interfaceBuildAgentConfigurationEx
- Returns:
- proxy login/password pair that should be used for connection to TeamCity Server, or null if proxy doesn't requre authentication
- See Also:
BuildAgentConfigurationEx.getServerProxyHost()
-
setTempDir
public void setTempDir(@NotNull String pathToTempDir)
Description copied from interface:BuildAgentConfigurationEx
Sets new path to temp directory- Specified by:
setTempDir
in interfaceBuildAgentConfigurationEx
- Parameters:
pathToTempDir
- new path to temp directory
-
getSystemInfo
@NotNull public BuildAgentSystemInfo getSystemInfo()
Description copied from interface:BuildAgentConfiguration
Returns agent jvm(system) information- Specified by:
getSystemInfo
in interfaceBuildAgentConfiguration
- Returns:
- agent jvm(system) information
-
getWorkDirectory
@NotNull public File getWorkDirectory()
Description copied from interface:BuildAgentConfiguration
Returns path to AGENT_INSTALL_DIR/work directory- Specified by:
getWorkDirectory
in interfaceBuildAgentConfiguration
- Returns:
- see above
-
getTempDirectory
@NotNull public File getTempDirectory()
Description copied from interface:BuildAgentConfiguration
Returns path to temp directory: parent folder of agent temp directory and build temp directory By default it returns INSTALL_DIR/temp, but that may be changes in buildAgent.properties file.- Specified by:
getTempDirectory
in interfaceAgentConfiguration
- Specified by:
getTempDirectory
in interfaceBuildAgentConfiguration
- Returns:
- see above
-
getSystemDirectory
@NotNull public File getSystemDirectory()
Description copied from interface:BuildAgentConfiguration
Returns path to a folder containing all system caches.- Specified by:
getSystemDirectory
in interfaceBuildAgentConfiguration
- Returns:
- see above
-
getBuildTempDirectory
@NotNull public File getBuildTempDirectory()
Description copied from interface:BuildAgentConfiguration
Returns path to a folder underBuildAgentConfiguration.getTempDirectory()
. This folder is cleaned before build is started.- Specified by:
getBuildTempDirectory
in interfaceBuildAgentConfiguration
- Returns:
- see above
-
getAgentTempDirectory
@NotNull public File getAgentTempDirectory()
Description copied from interface:BuildAgentConfiguration
Returns path to a folder underBuildAgentConfiguration.getTempDirectory()
. This folder is cleaned before build is started.- Specified by:
getAgentTempDirectory
in interfaceBuildAgentConfiguration
- Returns:
- file to agent's temp dir. All temp files of agent should be put under that folder
-
getAgentToolsDirectory
@NotNull public File getAgentToolsDirectory()
Description copied from interface:BuildAgentConfiguration
Provides path to tools folder on build agent. Returned folder is an existing path on the disk.- Specified by:
getAgentToolsDirectory
in interfaceAgentConfiguration
- Specified by:
getAgentToolsDirectory
in interfaceBuildAgentConfiguration
- Returns:
- path to agent tools folder
-
getCacheDirectory
@NotNull public File getCacheDirectory()
Description copied from interface:BuildAgentConfigurationEx
Returns path to a folder underBuildAgentConfiguration.getTempDirectory()
Temp directory for build agent instance is set to that folder. This folder is cleaned on build agent start. The same values is set to java.io.tmpdir system property- Specified by:
getCacheDirectory
in interfaceBuildAgentConfigurationEx
- Returns:
- see above
-
getCacheDirectory
@NotNull public File getCacheDirectory(@NotNull String key)
Description copied from interface:BuildAgentConfiguration
Returns path to a folder under agent's system directory by a key. It is guaranteed the folder exists. Use this folder to store some persistent data on the agent. Note: No cleaning is performed by the agent!- Specified by:
getCacheDirectory
in interfaceBuildAgentConfiguration
- Parameters:
key
- plugin unique key- Returns:
- path to a directory
-
getServerUrl
@NonNls public String getServerUrl()
Description copied from interface:BuildAgentConfiguration
Returns server URL- Specified by:
getServerUrl
in interfaceAgentConfiguration
- Specified by:
getServerUrl
in interfaceBuildAgentConfiguration
- Returns:
- server URL
-
addCustomProperty
public void addCustomProperty(@NotNull String name, @NotNull String value)
Description copied from interface:BuildAgentConfiguration
Adds new custom property to the configuration- Specified by:
addCustomProperty
in interfaceBuildAgentConfiguration
- Parameters:
name
- property namevalue
- property value
-
addConfigurationParameter
public void addConfigurationParameter(@NotNull String name, @NotNull String value)
Description copied from interface:BuildAgentConfiguration
Adds all-builds wide configuration parameter. Modifications will be available for all builds on this agent- Specified by:
addConfigurationParameter
in interfaceBuildAgentConfiguration
- Parameters:
name
- namevalue
- value
-
removeConfigurationParameter
public boolean removeConfigurationParameter(@NotNull String name)
Description copied from interface:BuildAgentConfiguration
Remove build agent configuration parameter added via @code(addConfigurationParameter) method. Will not remove parameter specified in buildAgent.properties file.- Specified by:
removeConfigurationParameter
in interfaceBuildAgentConfiguration
- Parameters:
name
- name- Returns:
- true if parameter was actually deleted, false otherwise (e.g parameter doesn't exist or is specified in buildAgent.properties file)
-
getOwnPort
public int getOwnPort()
Description copied from interface:BuildAgentConfiguration
Returns port where agent accepts commands from the server- Specified by:
getOwnPort
in interfaceBuildAgentConfiguration
- Returns:
- see above
-
getOwnAddress
public String getOwnAddress()
Description copied from interface:BuildAgentConfiguration
Returns IP address where agent accepts commands from the server- Specified by:
getOwnAddress
in interfaceBuildAgentConfiguration
- Returns:
- see above
-
initFrom
public void initFrom(File propertiesFile)
Description copied from interface:BuildAgentConfigurationEx
Loads configuration from the properties file- Specified by:
initFrom
in interfaceBuildAgentConfigurationEx
- Parameters:
propertiesFile
- properties file
-
getPropertiesFile
public File getPropertiesFile()
-
getName
public String getName()
Description copied from interface:BuildAgentConfiguration
Returns name of the agent- Specified by:
getName
in interfaceBuildAgentConfiguration
- Returns:
- name of the agent
-
setServerUrl
public void setServerUrl(String serverUrl)
Description copied from interface:BuildAgentConfigurationEx
Sets new server URL- Specified by:
setServerUrl
in interfaceBuildAgentConfigurationEx
- Parameters:
serverUrl
- server URL
-
setOwnPort
public void setOwnPort(int ownPort)
Description copied from interface:BuildAgentConfigurationEx
Changes agent port- Specified by:
setOwnPort
in interfaceBuildAgentConfigurationEx
- Parameters:
ownPort
- port
-
setName
public void setName(String name)
Description copied from interface:BuildAgentConfigurationEx
Changes agent name- Specified by:
setName
in interfaceBuildAgentConfigurationEx
- Parameters:
name
- agent name
-
setAuthorizationToken
public void setAuthorizationToken(@NotNull String token)
Description copied from interface:BuildAgentConfigurationEx
Changes agent authorization token- Specified by:
setAuthorizationToken
in interfaceBuildAgentConfigurationEx
- Parameters:
token
- agent authorization token
-
shouldSkipPluginsHashCheck
public boolean shouldSkipPluginsHashCheck()
- Specified by:
shouldSkipPluginsHashCheck
in interfaceAgentConfiguration
-
isLoadingToolsOnDemandAllowing
public boolean isLoadingToolsOnDemandAllowing()
- Specified by:
isLoadingToolsOnDemandAllowing
in interfaceAgentConfiguration
- Specified by:
isLoadingToolsOnDemandAllowing
in interfaceBuildAgentConfigurationEx
- Returns:
- true if agent can download tools which support loading on demand at runtime, false otherwise
-
isAgentUpgradeWithoutRestartAllowed
public boolean isAgentUpgradeWithoutRestartAllowed()
- Specified by:
isAgentUpgradeWithoutRestartAllowed
in interfaceAgentConfiguration
-
isToolsRemovalWithoutRestartAllowed
public boolean isToolsRemovalWithoutRestartAllowed()
- Specified by:
isToolsRemovalWithoutRestartAllowed
in interfaceAgentConfiguration
-
addEnvironmentVariable
public void addEnvironmentVariable(@NotNull String key, @NotNull String value)
Description copied from interface:BuildAgentConfiguration
Adds all-builds wide environment variable. Creates build parameters withConstants.ENV_PREFIX
prefix Note, on Windows machines environment size can be limited. Modifications will be available for all builds on this agent- Specified by:
addEnvironmentVariable
in interfaceBuildAgentConfiguration
- Parameters:
key
- name (without the "env." prefix), may be case sensitive or not depending on OSvalue
- value
-
addSystemProperty
public void addSystemProperty(@NotNull String key, @NotNull String value)
Description copied from interface:BuildAgentConfiguration
Adds all-builds wide system property. Creates build parameters withConstants.SYSTEM_PREFIX
prefix Modifications will be available for all builds on this agent- Specified by:
addSystemProperty
in interfaceBuildAgentConfiguration
- Parameters:
key
- property name (without the "system." prefix)value
- property value
-
getBuildParameters
@NotNull public BuildParametersMap getBuildParameters()
Description copied from interface:BuildAgentConfiguration
Returns build parameters. Some of values may not be fully resolved.- Specified by:
getBuildParameters
in interfaceBuildAgentConfiguration
- Returns:
- build-wide build parameters
-
getAgentConfDirectory
@NotNull public File getAgentConfDirectory()
- Specified by:
getAgentConfDirectory
in interfaceBuildAgentConfigurationEx
- Returns:
- path to agent conf directory
-
getAgentLibDirectory
@NotNull public File getAgentLibDirectory()
- Specified by:
getAgentLibDirectory
in interfaceBuildAgentConfiguration
- Returns:
- returns path to agent's lib dir
-
getAgentPluginsDirectory
@NotNull public File getAgentPluginsDirectory()
- Specified by:
getAgentPluginsDirectory
in interfaceAgentConfiguration
- Specified by:
getAgentPluginsDirectory
in interfaceBuildAgentConfiguration
- Returns:
- path to agent's plugins dir
-
getAgentUpdateDirectory
@NotNull public File getAgentUpdateDirectory()
- Specified by:
getAgentUpdateDirectory
in interfaceAgentConfiguration
- Specified by:
getAgentUpdateDirectory
in interfaceBuildAgentConfiguration
- Returns:
- path to agent's update dir
-
getAgentHomeDirectory
@NotNull public File getAgentHomeDirectory()
- Specified by:
getAgentHomeDirectory
in interfaceAgentConfiguration
- Specified by:
getAgentHomeDirectory
in interfaceBuildAgentConfiguration
- Returns:
- path to agent home
-
getAgentLogsDirectory
@NotNull public File getAgentLogsDirectory()
Description copied from interface:BuildAgentConfiguration
Returns directory containing agent log files- Specified by:
getAgentLogsDirectory
in interfaceBuildAgentConfiguration
- Returns:
- directory containing agent log files
-
getAgentZipName
@NotNull public String getAgentZipName()
- Specified by:
getAgentZipName
in interfaceAgentConfiguration
-
getUpdateContentsXmlName
@NotNull public String getUpdateContentsXmlName()
- Specified by:
getUpdateContentsXmlName
in interfaceAgentConfiguration
-
getUpdatePluginsBasePath
@NotNull public String getUpdatePluginsBasePath()
- Specified by:
getUpdatePluginsBasePath
in interfaceAgentConfiguration
-
-