Adding an artifact when running a plugin

Hi,

Does anyone know if it is possible to tell teamcity to pick up an artifact through the plugin code?  If yes, can you provide an example?  Basically if a build feature plugin is enabled I would like to automatically attach a file that is created via the plugin on the agent without having the user add it to the Artifacts Path build configuration each time.  Any help would be appreciated.

Thanks,
Jay

0
5 comments
Avatar
Permanently deleted user

Bump!

0

Hello,
please sorry for delay.

There are at least two ways of doing this:

He first way is to use TeamCity API. For this, add a constructor parameter to your plugins class that is registered in spring (on agent):

jetbrains.buildServer.agent.artifacts.ArtifactsWatcher

this class contains method: #addNewArtifactsPath(String)
The parameter of the method is the same string as you may specify on artifact paths in build configuration settings, general page.

Another way to add custom artifact while a build is to print a service message into build log,
See documentation for details, http://confluence.jetbrains.net/display/TCD65/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-PublishingArtifactswhiletheBuildisStillinProgress

0
Avatar
Permanently deleted user

Hi Eugene,

Thanks for getting back to me.  Using the ArtifactWatcher is the approach I took and it is working:

public AgentListener(@NotNull EventDispatcher<AgentLifeCycleListener> dispatcher,
                         @NotNull final CharlesLogger logger, @NotNull ArtifactsWatcher artifactsWatcher) {


Thanks for the help.

Jay

0

This is the right code sample. Please note, you may only use ArtifactsPublisher while agent is running a build. Note, it is not possible to use publisher in buildFinished() event, but possible to use in beforeBuildFinish event.

0
Avatar
Permanently deleted user

Thanks for the heads up.  I'm actually already using it in a method that is called from beforeBuildFinish so I'm good.

0

Please sign in to leave a comment.