This is part four of the five-part series on working with Kotlin to create Configuration Scripts for TeamCity.
and in turn if Prepare Artifacts had dependencies on previous build configurations, we'd define these in the dependencies segment of its build configuration.
Pipeline is a sequence of phases, phase is a set of buildTypes, each buildType in a phase depends on all buildTypes from the previous phase. This can handle simple but common kind of build chains where some build produces an artifact, several builds test it in parallel and the final build deploys the result if all its dependencies are successful.
Defining this at the Project.kt level in our DSL, would give us a good oversight of what's taking place.
The issue is though that currently the TeamCity DSL does not provide this functionality. But that's where Kotlin's extensibility proves quite valuable as we'll see.
What the code above is doing is define a series of new constructs, namely pipeline and phase.
The code then takes the contents of what's passed into each of these and defines, under the covers, the dependencies. In essence, it's doing the same thing we would do in each of the different build configurations, but from a global perspective defined at the Project level.
It's important to understand that this is just one of many ways in which we can define pipelines. We've used the terms pipeline and phase. We could just as well have used the term stage to refer to each phase, or buildchain to refer to the pipeline itself (and thus align it with the UI). In addition to how we've named the constructs, and more importantly, is how the definition is actually constructed. In our case, we were interested in having this present in the Project itself. But we could just as well define a different syntax that is used at the build type level. The ability to easily extend the TeamCity DSL with our own constructs, provides us with this flexibility.
This entry was posted in Features, How-To's, Tips&Tricks. Bookmark the permalink.
Is there a way to share code between different projects? Or only copy/paste is available?