Conditional step with kotlin dsl

Hello, everyone!


Is it possible to generate a script with conditional step dependant on value of build parameter or environment variable? I tried to access environment, but got AccessControlException from java when loading config from vcs.  i'v also tried to use  if ("%runstep%" == "yes") ...  wich leads to false (of course) because there is no parameters preprocessing. So i'm stuck with it. 

What i want to achive is something like this:

object TestKtl_Test : BuildType({
uuid = "bee54548-6165-4c1c-8282-1b063288c0c4"
name = "test"

params {
add {
param("env.RUNBUILD", "no")

steps {
if ("%env.RUNBUILD%" == "yes"){
script {
scriptContent = "echo yo"
1 comment
Comment actions Permalink

Hi Dmitry,


No, it's still not possible to run conditional steps. The TeamCity server loads the DSL and converts it to the same structures that the non-DSL uses, which means that features not available for the UI won't be available for the DSL.


In your case, the option would be to add the condition check as a first part of the script, or first step of the build, and don't run the script if the condition for running it is not met.


Please watch and vote here:


Please sign in to leave a comment.