Getting build artifact name

Hi,
When we generate our artifacts there is a build number inserted in the to resulting file, e.g.:
My_file.X.X.XXX.exe

I'm writing some python unit tests and there is no easy way pass a variable (the artifact name) to unit tests.
Therefore I was hoping to get the artifact name from the teamcity server using the pattern:
httpAuth/repository/download/btXXX/.lastSuccessful/My_file.X.X.XXX.exe
Given that wildcards don't work and not knowing the the version is problem so was thinking about using the teamcity-ivy.xml file.
As part of the unit test setup, parsing this file would give the full artifact name enabling me to copy if from the teamcity server.
However there doesn't seem to be anyway of getting this file without authentication on the teamcity server, I'd rather not store the username/pass in my python script.
You can't setup guest when using LDAP authentication.

Whats the best way to get either, teamcity-ivy.xml or the artifact, without authentication.


Thanks
Satpal

2 comments
Comment actions Permalink

If  you are writing python scripts for your unit tests.
Then you can simply read the build number from an environment variable using the pythons os.getenv  command

If your unit tests are in a seperate TeamCity project then setting an environment variable is easy

Assuming the project which created the artifact file is the one that gave it its build numbe.
Add this project to the dependency list of the unit test project
In the build paramaters   add a new parameter of type environments.
Chose a suitable name..  env.MyBuildNumerber  
In the value field enter %dep.btXX.build.number%  where is XX is the number of the project that created the artifact file.  ( You can get this number by opening this project and in your browser address bar  you will see  the number eg. BT11)
This environment variable will then be set to the build number on whatever agent is running your python unit tests.


An alternative is to simple pass the variable as a command line parameter in your build step   eg.    M_PYTHON_TESTS.py     %dep.btXX.build.number%

The trick is to make sure you add the project that created the build number as a  dependancy in your unit test project

0
Comment actions Permalink

Stewy,
Thanks for your answer. It looks sensible, however the problem is that python unit tests don't take arguments easily so it would be hard to use in that way.
It could be possible to read the env var from the python unit test however teamcity seems to run in a shell that gets taken down which means the env var would not survive. Also we are looking to move to jenkins, possibly for the testing so the env var wouldn't work.

I would still be interested in finding out howto get the artifacts/teamcity-ivy.xml without authentication.


Thanks
Satpal

0

Please sign in to leave a comment.