Package jetbrains.buildServer.agent.impl
Class BuildRunnerContextImpl
- java.lang.Object
-
- jetbrains.buildServer.agent.impl.BuildRunnerContextImpl
-
- All Implemented Interfaces:
BuildRunnerContext
,BuildRunnerContextEx
,MutableParameters
public class BuildRunnerContextImpl extends Object implements BuildRunnerContextEx
- Author:
- Eugene Petrenko Created: 05.07.2010 21:39:56
-
-
Constructor Summary
Constructors Constructor Description BuildRunnerContextImpl(AgentRunningBuildEx build, BuildRunnerSettings runnerSettings, ToolProvidersRegistry toolRegistry, BuildRunnerUnresolvedParametersEx parameters, UnresolvedParametersFactory unresolvedParametersFactory, VirtualContext nonVirtualContext, VirtualContext defaultDockerVirtualContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addBuildParameter(String key, String value)
void
addConfigParameter(String key, String value)
Adds configuration parameter ONTO this build runner state ONLY.void
addEnvironmentVariable(String key, String value)
Adds environment variable ONTO this build runner state ONLY.Disposable
addParametersUpdateListener(Runnable r)
void
addRunnerParameter(String key, String value)
Adds runner parameter for current build runner.void
addSystemProperty(String key, String value)
Adds build system property ONTO this build runner state ONLY.void
cleanParameters()
AgentRunningBuild
getBuild()
Return agent running build instance of current build runner contextBuildParametersMap
getBuildParameters()
Returns current runner build parameters with all references expandedMap<String,String>
getConfigParameters()
Returns current runner's configuration parameters with all references expandedString
getFullId()
String
getId()
String
getName()
Collection<? extends ParameterResolveIssue>
getParameterResolveIssues()
ValueResolver
getParametersResolver()
Creates value resolver for parameters resolution in strings.Map<String,String>
getRunnerParameters()
Returns unmodifiable map of runner parameters with all references expandedBuildRunnerUnresolvedParametersEx
getRunnerUnresolvedParameters()
String
getRunType()
String
getToolPath(String toolName)
Returns path to a tool with given nameUnresolvedParameters
getUnresolvedParameters()
VirtualContext
getVirtualContext()
File
getWorkingDirectory()
Returns current runner working directory.boolean
isVirtualContext()
boolean
parametersHaveReferencesTo(Collection<String> keys)
Finds usages of any of the given keys in all build and runner parametersvoid
setVirtualContext(boolean virtualContext)
Deprecated.void
setVirtualContext(VirtualContext virtualContext)
-
-
-
Constructor Detail
-
BuildRunnerContextImpl
public BuildRunnerContextImpl(@NotNull AgentRunningBuildEx build, @NotNull BuildRunnerSettings runnerSettings, @NotNull ToolProvidersRegistry toolRegistry, @NotNull BuildRunnerUnresolvedParametersEx parameters, @NotNull UnresolvedParametersFactory unresolvedParametersFactory, @NotNull VirtualContext nonVirtualContext, @NotNull VirtualContext defaultDockerVirtualContext)
-
-
Method Detail
-
getId
public String getId()
- Specified by:
getId
in interfaceBuildRunnerContext
- Returns:
- build runner Id from server
-
getFullId
@NotNull public String getFullId()
- Specified by:
getFullId
in interfaceBuildRunnerContextEx
- Returns:
- Full build runner Id including all parents Ids. Ids are separated with ':', eg RUNNER_1:runner_step1:runner_substep2
- See Also:
BuildRunnerSettings.getParent()
,BuildRunnerSettings.getChildren()
-
getBuild
@NotNull public AgentRunningBuild getBuild()
Description copied from interface:BuildRunnerContext
Return agent running build instance of current build runner context- Specified by:
getBuild
in interfaceBuildRunnerContext
- Returns:
- build from what this runner context was created
-
getName
@NotNull public String getName()
- Specified by:
getName
in interfaceBuildRunnerContext
- Returns:
- build runner descriptor name, defined by the user
-
addParametersUpdateListener
@NotNull public Disposable addParametersUpdateListener(@NotNull Runnable r)
- Specified by:
addParametersUpdateListener
in interfaceMutableParameters
-
getParameterResolveIssues
@NotNull public Collection<? extends ParameterResolveIssue> getParameterResolveIssues()
- Specified by:
getParameterResolveIssues
in interfaceBuildRunnerContextEx
-
getConfigParameters
@NotNull public Map<String,String> getConfigParameters()
Description copied from interface:BuildRunnerContext
Returns current runner's configuration parameters with all references expanded- Specified by:
getConfigParameters
in interfaceBuildRunnerContext
- Returns:
- see above
-
getUnresolvedParameters
@NotNull public UnresolvedParameters getUnresolvedParameters()
- Specified by:
getUnresolvedParameters
in interfaceBuildRunnerContextEx
-
addEnvironmentVariable
public void addEnvironmentVariable(@NotNull String key, @NotNull String value)
Description copied from interface:BuildRunnerContext
Adds environment variable ONTO this build runner state ONLY. Creates build parameters withConstants.ENV_PREFIX
prefix Note, on Windows machines environment size can be limited. NOTE:. Modification will only affect current build runner state. Modifications will NOT be available in anther build runner states.- Specified by:
addEnvironmentVariable
in interfaceBuildRunnerContext
- Parameters:
key
- name, may be case sensitive or not depending on OSvalue
- value
-
getParametersResolver
@NotNull public ValueResolver getParametersResolver()
Description copied from interface:BuildRunnerContext
Creates value resolver for parameters resolution in strings. The resolution rules are the same as for build parameters- Specified by:
getParametersResolver
in interfaceBuildRunnerContext
- Returns:
- value resolver to perform resolution of all parameters references within string
-
addSystemProperty
public void addSystemProperty(@NotNull String key, @NotNull String value)
Description copied from interface:BuildRunnerContext
Adds build system property ONTO this build runner state ONLY. Creates build parameters withConstants.SYSTEM_PREFIX
prefix NOTE:. Modification will only affect current build runner state. Modifications will NOT be available in anther build runner states.- Specified by:
addSystemProperty
in interfaceBuildRunnerContext
- Parameters:
key
- property namevalue
- property value that may contain references
-
getWorkingDirectory
@NotNull public File getWorkingDirectory()
Description copied from interface:BuildRunnerContext
Returns current runner working directory. This directory is expected to be set as working directory in a build process that build runner will start.- Specified by:
getWorkingDirectory
in interfaceBuildRunnerContext
- Returns:
- path
-
getRunType
@NotNull public String getRunType()
- Specified by:
getRunType
in interfaceBuildRunnerContext
- Returns:
- current runner type of the build
-
getBuildParameters
@NotNull public BuildParametersMap getBuildParameters()
Description copied from interface:BuildRunnerContext
Returns current runner build parameters with all references expanded NOTE: Parameters may contain modifications for current state only- Specified by:
getBuildParameters
in interfaceBuildRunnerContext
- Returns:
- see above
-
getRunnerParameters
@NotNull public Map<String,String> getRunnerParameters()
Description copied from interface:BuildRunnerContext
Returns unmodifiable map of runner parameters with all references expanded- Specified by:
getRunnerParameters
in interfaceBuildRunnerContext
- Returns:
- see above
-
cleanParameters
public void cleanParameters()
- Specified by:
cleanParameters
in interfaceBuildRunnerContextEx
-
addBuildParameter
public void addBuildParameter(@NotNull String key, @NotNull String value)
- Specified by:
addBuildParameter
in interfaceBuildRunnerContextEx
-
addConfigParameter
public void addConfigParameter(@NotNull String key, @NotNull String value)
Description copied from interface:BuildRunnerContext
Adds configuration parameter ONTO this build runner state ONLY. NOTE:. Modification will only affect current build runner state. Modifications will NOT be available in anther build runner states.- Specified by:
addConfigParameter
in interfaceBuildRunnerContext
- Parameters:
key
- name, may be case sensitive or not depending on OSvalue
- value
-
addRunnerParameter
public void addRunnerParameter(@NotNull String key, @NotNull String value)
Description copied from interface:BuildRunnerContext
Adds runner parameter for current build runner. NOTE:. Modification will only affect current build runner state. Modifications will NOT be available in anther build runner states.- Specified by:
addRunnerParameter
in interfaceBuildRunnerContext
- Parameters:
key
- keyvalue
- value
-
parametersHaveReferencesTo
public boolean parametersHaveReferencesTo(@NotNull Collection<String> keys)
Description copied from interface:BuildRunnerContext
Finds usages of any of the given keys in all build and runner parameters- Specified by:
parametersHaveReferencesTo
in interfaceBuildRunnerContext
- Parameters:
keys
- the collection of keys- Returns:
- true if a usage of any given keys is found
-
isVirtualContext
public boolean isVirtualContext()
- Specified by:
isVirtualContext
in interfaceBuildRunnerContext
- Returns:
- true if the given step will be run under a virtual environment (Docker) and the runner should not expect presence of tools non-bundled with the agent (located on build agent FS).
-
setVirtualContext
@Deprecated public void setVirtualContext(boolean virtualContext)
Deprecated.- Specified by:
setVirtualContext
in interfaceBuildRunnerContextEx
- Parameters:
virtualContext
- Mostly for Docker plugin to mark the build step/context as virtual one so build runner won't look for tools on the agent in advance (they may be provided in the docker image)
-
setVirtualContext
public void setVirtualContext(@NotNull VirtualContext virtualContext)
- Specified by:
setVirtualContext
in interfaceBuildRunnerContextEx
- Parameters:
virtualContext
- Mostly for Docker plugin to specify current virtual context in the scope of build step
-
getVirtualContext
@NotNull public VirtualContext getVirtualContext()
- Specified by:
getVirtualContext
in interfaceBuildRunnerContext
- Returns:
- current virtual context in the scope of build step
-
getRunnerUnresolvedParameters
@NotNull public BuildRunnerUnresolvedParametersEx getRunnerUnresolvedParameters()
- Specified by:
getRunnerUnresolvedParameters
in interfaceBuildRunnerContextEx
-
getToolPath
@NotNull public String getToolPath(@NotNull String toolName) throws ToolCannotBeFoundException
Description copied from interface:BuildRunnerContext
Returns path to a tool with given name- Specified by:
getToolPath
in interfaceBuildRunnerContext
- Parameters:
toolName
- name of the tool- Returns:
- path to a tool on the filesystem
- Throws:
ToolCannotBeFoundException
- if path to a tool can't be located
-
-