Meta runner parameters
I am having trouble understanding how parameters can work within metarunners.
Given the following example where an exe name is specified, the full path is resolved by powershell from the working dir, how can this then be passed to the second runner?
Updating the param via setParameter does not work
<?xml version="1.0" encoding="UTF-8"?> <meta-runner name="Test"> <description>ParamTest</description> <settings> <parameters> <param name="mr.executable" value="some.exe" spec="text description='The executable' display='normal' label='Executable'" /> </parameters> <build-runners> <runner name="Runner1" type="jetbrains_powershell"> <parameters> <param name="jetbrains_powershell_execution" value="PS1" /> <param name="jetbrains_powershell_noprofile" value="true" /> <param name="jetbrains_powershell_errorToError" value="error" /> <param name="jetbrains_powershell_script_mode" value="CODE" /> <param name="jetbrains_powershell_bitness" value="x86" /> <param name="teamcity.step.mode" value="default" /> <param name="jetbrains_powershell_script_code"><![CDATA[[CmdletBinding()] Param ( [string] $workingDir = "%teamcity.build.workingDir%", [string] $ExeName = "%mr.executable%", ) $exe = Join-Path $workingDir "\*\$ExeName" | Resolve-Path Write-Host "##teamcity[setParameter name='mr.executable' value='$exe']" ]]></param> </parameters> </runner> <runner name="Run exe" type="jetbrains.dotNetGenericRunner"> <parameters> <param name="proc_bit" value="MSIL" /> <param name="proc_path">%mr.executable%</param> <param name="proc_runtime_version" value="v4.0" /> <param name="teamcity.step.mode" value="default" /> </parameters> </runner> </build-runners> <requirements /> </settings> </meta-runner>
,
Please sign in to leave a comment.
Did you try to create a build configuration from this meta runner and check whether it works?
Yes I did, it does not pass the updated variable value to the second runner, presumably as it is evaluated when the metarunner is loaded rather than when it is called and the powershell runs after this has happened.
[EDIT] I should add that the above sample has a typo or two, my real metarunner is doing lots more but the quickly hacky sample above captures the essence of the issue I'm having. It does run correctly and no matter what I've tried, I cannot update the final runner's param value in any previous runner within the same metarunner
Maybe the problem is in powershell line:
Write-Host ##teamcity[setParameter name='mr.executable' value='$exe']"
I see closing quote, but I don't see the quote in the beginning. Shouldn't it be:
Write-Host "##teamcity[setParameter name='mr.executable' value='$exe']"
?
see above edit, my value is being correctly set with correct quotes in log
Updated to fix missing quote
Ok I meant double quotes, I still do not see a double quote before ##teamcity.
fixed typo in hacky sample, still does not work though
Just tried similar setup with two command line runners: one outputs parameter using setParameter and another one uses this parameter as path to executable. It works just fine.
You should see actual value for mr.executable parameter on tab Parameters of the build.
does it modify the original mr.executable parameter or create a new one?
In my case I had parameter defined in build configuration and first step changed it.
Can you post metarunner xml?
Sure:
<?xml version="1.0" encoding="UTF-8"?>
<meta-runner name="Set Parameter Sample">
<description>Set parameter sample</description>
<settings>
<parameters>
<param name="cmd" value="" />
</parameters>
<build-runners>
<runner name="" type="simpleRunner">
<parameters>
<param name="script.content" value="echo "##teamcity[setParameter name='cmd' value='dir']"" />
<param name="teamcity.step.mode" value="default" />
<param name="use.custom.script" value="true" />
</parameters>
</runner>
<runner name="" type="simpleRunner">
<parameters>
<param name="command.executable" value="%cmd%" />
<param name="teamcity.step.mode" value="default" />
</parameters>
</runner>
</build-runners>
<requirements />
</settings>
</meta-runner>
I can't see this working, the param is set to 'a' in the build step, updated in the first meta runner to 'dir' and passed to the second runner as 'a', not the updated value 'dir'. Using 9.0.4 (build 32407)
What version of TeamCity do you use?
Using 9.0.4 (build 32407)
cut and paste your exact xml into metarunner with single build config, with single step, running said meta runner. It fails to update param. Anything I should turn on for extra log info?
Ok, so it works in build configuration but does not work in meta runner. I reproduced it locally and I found similar issue in our tracker: https://youtrack.jetbrains.com/issue/TW-35383
Please watch for it.
Thanks, can this issue be marked as verified then as you and I can both reproduce it.
Also just noticed that this was raised on 01 Mar 2014 and has had 0 progress in that time. Should I expect this never to get fixed?
In issue tracker? We use this field when issue is fixed and verified by qa.
Landed on this problem when trying to make a half decent metarunner and noticed I couldn't pass arguments between two scripts.
This problem was initiated in 2015 and is still not fixed?
Harald S Hanssen Hi, I can see the sample meta-runner Pavel provided above working on 2022.2.2 after a minor edit (see the snippet below) and setting the build configuration parameter cmd value to %cmd% in build configuration settings > Parameters. Can you try that meta-runner for troubleshooting reasons or share your meta-runner?
Cool I'll look into it :)
Have to clear a bit of time to test it out.