Teamcity chained pipelines and build lifecycle

I want to implement chained build pipelines, i.e. have a pipeline as code in a file in my main project source repository, where the pipeline may have other build steps defined elsewhere executed before and after my build steps. I don't have access to define the pre and post steps.

Imagine wanting to build a container, where company policy is to want to define pre and post build screening steps. A executed, followed by my job J, followed by B. A and B are defined by a security department, developers define J only.

Additionally, the build is to be done via a plugin that will create ephemeral build agents. I'm going to need to write a plugin as the Jetbrains one is not prod-ready and doesn't function as required.

My questions:

Do Teamcity build configurations get saved in SCM in the same repository as the rest of the project source code? Or are they saved to a separate SCM repository?
I could implement this in a couple of ways:

a. All container builds are defined as a separate job, J1, J2, ... Jn. Each job needs to be manually wired to A and B. If we need at a later stage to insert job C between J and B, there are a lot of jobs that need rewiring. Is there a way of injecting dependencies into the execution DAG, after J is triggered, such that A, B and C are executed without needing to manually define the dependencies? Or is the DAG fully defined once you get notified of the build?

b. I could define A and B in containers, then have a build agent + build runner container execute A, then the commands in J, then B. This container runner would be a sort of orchestrator. Adding C would require changing the orchestrator, but would mean there would be no need to wire A to J to C to B. This would have the additional benefit of linking the build of J to artefacts A, B and C, which would make the audit trail immutable. Is this a viable approach?
Is there any documentation on the lifecycle of events across the server and agent available to plugins throughout the lifecycle of a build? The documentation is pretty sparse in regards to custom plugins.

Please sign in to leave a comment.