Andrey Ermakov
Andrey Ermakov

Reputation: 3338

What is a replacement for meta runners in TeamCity Kotlin DSL?

Apparently there's no support for metarunners generation in TeamCity Kotlin DSL. The files remain in plain XML.

How do I replace it using available DSL features? Say I'd like to do this:

steps {
  step {
    type = "mymetarunner" // compound meta-runner step
  }
}

How do I define mymetarunner using Kotlin?

Upvotes: 4

Views: 1114

Answers (1)

Nikita Skvortsov
Nikita Skvortsov

Reputation: 4923

At the moment (TeamCity 2017.2), there is no way to define metarunners using Kotlin DSL.

Update If having a real metarunner is not required, the solution is a small exercise in Kotlin DSL

Define a container class for settings you need for "metarunner"

class MyConfigClass {
  var name = "Default Name"
  var goals = "build"
  var tasks = "build test"
  var someUnusedProperty = 0
}

Define an extension function for steps block

fun BuildSteps.myMetaRunner(config: MyConfigClass.() -> Unit) {
  val actualConfig = MyConfigClass() // new config instance
  actualConfig.config()  // apply closure to fill the config
  // use the config to create actual steps
  maven {
      name = actualConfig.name
      goals = actualConfig.goals
  }

  ant {
      name = actualConfig.tasks
  }
}

Use the extension function wherever you need

object A_Build : BuildType({
  uuid = ... 

  steps {
    myMetaRunner {
      name = "This name will be used by maven step"
      goals = "build whatever_goal"
      tasks = "more ant tasks"
    }
  }
})

Bingo!

Upvotes: 5

Related Questions