Hi. Testing the waters here to see if anyone is st...
# teamcity
a
Hi. Testing the waters here to see if anyone is still active here 😬 I'm working on an internal DSL to make interfacing with TeamCity easier for our developers. It seems to run well enough when running the mvn:generate action on an actual pipeline, but writing test-code has proven to be quite the challenge. Even with this block
Copy code
fun generate() {
        project {
            internalBuildTypes.forEach {
                buildType(it)
            }
        }
    }
I get an error
Project builder is not provided
which I cannot get to the bottom off. Anyone have some pointer? Be happy to provide more code if needed!
You had a blog-post were you wrote some basic test-code for teamcity DSLs @antonarhipov, maybe you have some pointers?
a
ahhh, TeamCity DSL.. long time no see 😅 I doubt I can suggest the right thing from the top of my head. I’d need to allocate some time to recall the subject. But it’s best to ask someone from TeamCity devs about it. Let me ping someone in the team
Looking at https://blog.jetbrains.com/teamcity/2019/05/configuration-as-code-part-6-testing-configuration-scripts/ What if you configure this with an
object X: Project
, instead of
project {}
?
the pipelines dsl did not exist at the time when I wrote the tutorial so I haven’t experimented with that in the tests
a
Thanks 🙏 Yeah, definitely found some quirks, but also found a workaround now. Rather than having an internal
private val project: Project
variable in my
PipelineBuilder
and appending the buildTypes onto that, I opted to use the same setup as the TeamCity dsl uses internally, by storing the buildTypes in the
PipelineBuilder
and then providing the projectbuilder directly in the
ProjectBuilder#generate
method above
Copy code
fun generate(): Project {
        return Project {
            parameters.forEach { params.add(it) }
            this@PipelineBuilder.buildTypes.forEach(::buildType)
        }
    }
This seems to work so I'll leave it at that for now, but if some of the devs stumble upon this I'll be happy to provide more 😅 Thanks for some pointers @antonarhipov 🎉 Gotta say that having the option to build an internal DSL for teamcity stuff is pretty cool though 😅
👍 1
a
Just confirmed with devs - yeah,
project {}
cannot be used in tests because of the required builder. Makes sense to document it though.
a
Gotcha! Then it's even weirder that I got it to work I guess, but I'm happy for now 😅
maybe there's an internal difference between the
Project {}
and the
project {}
builders 🤪
a
yes, there is
👍 1
a
Right, then the solution makes sense at least 🙂 But yeh, having a sentence about that in the docs would be 💯