kotlin dsl: How to disable a step?

After converting to kotlin, disablabled steps looks like

disableSettings("RUNNER_166", "RUNNER_167", "RUNNER_394")

But how would I disable a custom step that is defined in the template like

steps {
setVersionNumberJavaApp {}
...

Do I have to create hard-coded step-ids? Do I create them in the template here `setVersionNumberJavaApp` is used? Or should it be in the `setVersionNumberJavaApp` fun somehow?

class SetVersionNumberJavaApp {
var executionMode = BuildStep.ExecutionMode.ALWAYS
}

fun BuildSteps.setVersionNumberJavaApp(config: SetVersionNumberJavaApp.() -> Unit) {
script {
val aconfig = SetVersionNumberJavaApp()
aconfig.config()

name = "Set build version number"
executionMode = aconfig.executionMode
scriptContent = """
...

 

0
3 comments

Like this (kotlin newbe here):

class SetVersionNumberJavaApp {
companion object {
val id: String = SetVersionNumberJavaApp::class.java.name
}
var executionMode = BuildStep.ExecutionMode.ALWAYS
}

fun BuildSteps.SetVersionNumberJavaApp(config: SetVersionNumberJavaApp.() -> Unit) {
script {
val aconfig = SetVersionNumberJavaApp()
aconfig.config()

id = SetVersionNumberJavaApp.id
name = "Set build version number"
...

Then

disableSettings("RUNNER_166", "RUNNER_167", "RUNNER_394", SetVersionNumberJavaApp.id)

That's a lot of boilerplate though...

0

Hi Barry,

 

I'm not sure I fully understand the idea, but in the step itself (for example: script {}) you can set a field named "enabled" to false, just like you set the name. In your last example:


name = "Set build version number"

enabled = false

 

That should do the trick. Am I missing something?

0
Avatar
Permanently deleted user

In this case, the build is using a template, so there are not steps to set `enable` on.

0

Please sign in to leave a comment.