I have several script steps in Kotlin DSL for TeamCity. For example here I update the parameter that was changed in previous buildTypes.
script {
scriptContent = """
TEMP_VAR=${'$'}(curl --insecure -v --Header "Content-Type: text/plain" --user '%apiName%:%apiPassNew%' <TC-url>/httpAuth/app/rest/projects/<projectName>/parameters/%$myVar%)
echo "##teamcity[setParameter name='%$myVar%' value='${'$'}TEMP_VAR']"
""".trimIndent()
}
And then I have another script step that runs an ansible-playbook with extraVars. I want to move a JSON from extraVars to Kotlin collection, however, for this, I want to use Kotlin variables instead of TeamCity parameters. I could assign it like this
val kotlinVar = "%myParameterFromTeamCity%"
But how could I update the value of this parameter in the script block? For example, I have this part of pipeline.
var myVar = "%myParameterFromTeamCity%"
steps {
script {
scriptContent = """
TEMP_VAR=${'$'}(curl --insecure -v --Header "Content-Type: text/plain" --user '%apiName%:%apiPassNew%' <TC-url>/httpAuth/app/rest/projects/<projectName>/parameters/myParameterFromTeamCity)
""".trimIndent()
}
}
How could I set the value of TEMP_VAR to myVar after curl runs?