How to specify TeamCity configuration parameter for meta-runner?

I want to create a meta runner that asks the user to check the box (tooltip configuration parameter) to confirm deployment to production. It contains a powershell script, which are checked if the checkbox is checked. Here is the meta runner code:

<?xml version="1.0" encoding="UTF-8"?> <meta-runner name="Confirm deploy to production"> <description>Force user to check checkbox to confirm deploy to production</description> <settings> <parameters> <param name="deploy.to.production.confirmation.checkbox" value="false" spec="checkbox description='Are you sure?' label='This is deployment to PRODUCTION environment.' uncheckedValue='false' display='prompt' checkedValue='true'" /> </parameters> <build-runners> <runner name="Confirm deploy to production" type="jetbrains_powershell"> <parameters> <param name="jetbrains_powershell_bitness" value="x86" /> <param name="jetbrains_powershell_errorToError" value="false" /> <param name="jetbrains_powershell_execution" value="PS1" /> <param name="jetbrains_powershell_script_code"><![CDATA[trap { write-output $_ ##teamcity[buildStatus status='FAILURE' ] exit 1 } write-host "##teamcity[message text='Starting confirmation validation...']" if("%deploy.to.production.confirmation.checkbox%" -eq "false"){ write-host "##teamcity[message text='Confirmation validation FAILED' errorDetails='This is a production deployment. The confirm checkbox must be checked to proceed with the deploy process.' status='ERROR']" throw "Confirmation validation FAILED" } else { write-host "##teamcity[message text='Confirmation validation SUCCESSFUL']" }]]></param> <param name="jetbrains_powershell_script_mode" value="CODE" /> <param name="teamcity.step.mode" value="default" /> </parameters> </runner> </build-runners> <requirements /> </settings> </meta-runner> 

1) The first thing that the deploy.to.production.confirmation.checkbox parameter does not work as expected and does not show a confirmation dialog for each assembly, I can only specify it on the step configuration page.

2) Secondly, if I add the deploy.to.production.confirmation.checkbox parameter to my build configuration, it will suggest the value as expected, but that value will not be passed to the Powershell script.

How can I ask the user to specify some value (before running the assembly configuration) and then pass that value to the Powershell script?

+5
source share
1 answer

The <parameters> section declares assembly step level parameters, so you do not get tubes in the assembly. To get this, you need to declare the deploy.to.production.confirmation.checkbox parameter in the build configuration.

Then you can take this value and pass it to MetaRunner as follows:

 <param name="deploy.to.production.confirmation.checkbox" value="%deploy.to.production.confirmation.checkbox%" /> 

On the side, I agree with Jared Dykstra's comment. You should consider creating separate build configurations for this task.

0
source

Source: https://habr.com/ru/post/1235617/


All Articles