teamcity set environment variable command line

C++
Build Step #1:
#!/bin/bash
echo "##teamcity[setParameter name='env.ddd' value='fff']"
echo "##teamcity[setParameter name='env.datetime' value='$(date)']"

The values of initialized parameters will be avaliable on the next build step:

Build Step #2:
#!/bin/bash
echo $ddd
echo $datetime
Source

Also in C++: