Dependent build is not triggered
I have two builds:
- Test
- Phpstan
Phpstan requires artifacts from Test and should be triggered on a successful Test build with the same revision.
This is the snapshot dependency definition on the Phpstan build:
dependencies {
dependency(Test) {
snapshot {
runOnSameAgent = true
onDependencyFailure = FailureAction.CANCEL
onDependencyCancel = FailureAction.CANCEL
}
artifacts {
artifactRules = """
application/configs/di-parameters-local.php => application/configs/
application/configs/local-public.ini => application/configs/
application/configs/local-private.ini => application/configs/
?:application/models/propel.zip!** => application/models/propel/
""".trimIndent()
}
}
artifacts(RelativeId("Phpstan")) {
buildRule = lastFinished()
artifactRules = "?:application/tmp/phpstan.zip!** => application/tmp/phpstan"
}
}
When the Test build is triggered via vcs, Phpstan build isn't triggered though. The manual says the build with the snapshot dependency (Phpstan) needs a finishBuildTrigger definition:
If I add this definition in the Phpstan build:
triggers {
finishBuildTrigger {
buildType = "${Test.id}"
}
}
I get the following error:
Kotlin DSL compilation errors
Compilation error settings.kts[171:9]: Unresolved reference: finishBuildTrigger
Compilation error settings.kts[172:13]: Unresolved reference: buildType
Compilation error settings.kts[173:13]: Unresolved reference: successfulOnly
I've tried a lot of variations, but no success, any idea?
Please sign in to leave a comment.
Hi,
If you're defining all builds inside a settings.kts file and not splitting into *.kt classes with BuildType, then you can’t use finishBuildTrigger directly — it's unavailable in settings.kts.
You should move to defining builds using class-based BuildType objects (like above), which gives access to the full Kotlin DSL, including finishBuildTrigger.
By the way, have you tired of resolving it with a local IDE?
Best Regards,
Tom
thanks, splitting the build into build types resolves the finishBuildTrigger error
still struggling though, even after scanning the kotlin docs and resolving in my local ide…
i have a different BuildType defined in a separate file and would like to use the vcs trigger:
this produces the compilation error
Am I missing an import or something else?
Hi Martin,
This error usually means that the vcs function is being called in the wrong context. In TeamCity Kotlin DSL, the correct way to define a VCS trigger inside a BuildType is to use the vcs trigger function provided by the DSL, not a generic vcs function.
Inside your BuildType definition, the triggers block should look like this:
Note:
• You do not need to specify the VCS root here if it’s already attached to the build type via the vcs block at the top level of the build type.
• If you need to specify a particular VCS root, you can do so, but the syntax is slightly different.
Example BuildType
Hi Tom, thanks I appreciate your help on this.
I've tried omitting the VCS root before and I do not see a difference in my declaration in comparison to what you are describing.
This is my complete BuildType Definition (Test.kt):
Hi Martin,
I'd like to confirm whether you've imported the
jetbrains.buildServer.configs.kotlin.triggers.finishBuildTriggermodule in your Phpstan.kt file.According to the official documentation, the following usage should work:
Could you please double-check the import and ensure the syntax matches the example above? You also can Debug Kotlin DSL Scripts.
Best Regards,
Tom
The Phpstan.kt file compiles fine, there is no problem with the finishBuildTrigger anymore (the import is there as well).
The current problem relates to the use of
triggers {
vcs {
branchFilter = "+:refs/heads/*"
}
}
in another build type (Test.kt), see full source in my previous answer.
Trying to debug results in the aforementioned compilation error:
Compilation error _Self/buildTypes/Test.kt[23:9]: 'fun vcs(init: VcsSettings.() -> Unit): Unit' can't be called in this context by implicit receiver. Use the explicit one if necessary
Hi Martin,
Thanks for your update and confirmation.
It seems that the following import is missing in your Test.kt file:
Could you please add this import and try again?
Best Regards,
Tom