Agent-side Object Model
On the agent side agent is represented by jetbrains.buildServer.agent.BuildAgent4.5.1
interface. BuildAgent is available as a Spring bean and can be obtained by autowiring.
Build agent configuration can be read from the jetbrains.buildServer.agent.BuildAgentConfiguration4.5.1
, it can be obtained from the BuildAgent#getConfiguration() method.
Agent side events
There is jetbrains.buildServer.agent.AgentLifeCycleListener4.5.1
interface and corresponding adapter class jetbrains.buildServer.agent.AgentLifeCycleAdapter4.5.1
which can be used to receive notifications about agent side events, like starting of the build, build finishing and so on. Your listener must be registered in the jetbrains.buildServer.util.EventDispatcherAgentLifeCycleListener5.0.0
. This service is also defined in the Spring context.
Build
Each build on the agent is represented by jetbrains.buildServer.agent.AgentRunningBuild4.5.1
interface. You can obtain instance of AgentRunningBuild be listening for buildStarted(AgentRunningBuild) event in AgentLifeCycleListener.
Logging to build log
Messages to build log can be sent only when a build is running. Internally agent sends messages to server by packing them into the jetbrains.buildServer.messages.BuildMessage14.5.1
structures. However instead of creating BuildMessage1 structures it is better and easier to use corresponding methods in jetbrains.buildServer.agent.BuildProgressLogger4.5.1
which can be obtained from the AgentRunningBuild.
If you want to construct your own messages you can use static methods of jetbrains.buildServer.messages.DefaultMessagesInfo4.5.1
class for that.