TeamCity treats cmdline python script parameters as python list objects

1k views Asked by At

I am running a python (2) script using the TeamCity (10.x) command line runner.. The command executable is set as:

/usr/bin/python

And the script parameters are set as:

./some-python-script.py --mvn_version %maven.project.version% 
--artifact_id %maven.project.artifactId%

When processing these dynamically generated build parameters (from the previous maven runner build step, in the same build), TeamCity treats these parameters as list type objects by default!

So when trying to use the maven.project.version as part of my Nexus URL, I end up with a list as part of the url : https://nexus_server/nexus/service/local/repositories/myproject/content/my/maven/group/some_artifact/['2.141']

When running the same script on the Linux command line, the same parameter is treated as a string. As expected, due to (note type str):

parser.add_argument('-mv', '--mvn_vrsn', type=str, nargs=1, \
default='2.140.0-SNAPSHOT', help='TCity: maven.project.version')

... I get the expected result: https://nexus_server/nexus/service/local/repositories/myproject/content/my/maven/group/some_artifact/2.141

1

There are 1 answers

0
OneMoreNerd On

This can be solved by specifying a list element suffix for any TeamCity originating variables e.g.

mvn_vrsn[0] 

Which will produce 2.141 as opposed to ['2.141']!

Not ideal, but it works!