Build step before artifact pull or after artifact publish to clean

We are experimenting to use TeamCity with Plastic SCM. Plastic SCM seems undoing only changed files before switching to another changeset. We want to clear private and especially ignored files before starting a build configuration node. 
Since our repository size is quite large, clean checkout seems not an option. Swabra also takes time, it could be solved if we carefully add paths but it is error-prone since our ignored files scattered across project.

When we run a command to clean those files as a build step,  it removes pulled artifacts. Is there any easy solution to run a command between switching changeset and pulling artifacts OR after artifact publish is complete?

Two solutions were came to our mind
1- After manually triggering artifact publish if there is a way to check completion to wait in a build step,  it could help. 
2- If build features can be triggered at times I mentioned above, writing a custom plugin to add a build feature. Is there any example code to add basic build features?

Thank you,

Comment actions Permalink

Hello Bilal,

Unfortunately, there is no way to trigger a build step after the artifacts were published, and I do not think waiting for the "dynamic" publish to finish is supported either. However, implementing a custom plugin should work.

There is a number of events that happen during a build, and you may fire a function upon one of these methods. They are listed here; you may be particularly interested in implementing 

afterAtrifactsPublished(AgentRunningBuild, BuildFinishedStatus)


If you want to run this method only for the builds that have a certain build feature enabled, please see this article on how to create and register a simple build feature. There is a number of open-source plugins that implement their own build features; for example, you may check the Terraform plugin. The build feature has an agent-side part and a server-side part

For any questions you might have about the implementation, please feel free to reach out and I will try to assist further.

Comment actions Permalink

Hello Fedor,
Thank you for detailed information, I will examine those plugins.

If I am not wrong, I can get a notification after checkin and before artifact pull via listening 

Is this just a blocking notification? Can I do operations inside of it or is it just a momentary notification? If I can block the build inside of it I can remove private and ignored files after source update and before artifact pull here. ( It is the same question for `afterAtrifactsPublished`)

Comment actions Permalink

Hello Bilal,

Yes, code-wise it seems that these methods are synchronous (that is, the build should be blocked until the method execution is over). 


Please sign in to leave a comment.