TeamCity, passing an id generated in one build step to a later build step

前端 未结 1 1307
無奈伤痛
無奈伤痛 2020-12-04 19:19

New to TeamCity. I have multiple build steps. Step 3 generates an id that is needed in step 4. What is the best way to pass the id (a string) between step 3 and step 4?

相关标签:
1条回答
  • 2020-12-04 19:39

    Yes, you can set an environment variable in one build step and use it in the following step. You will need to use a service message in your build script as described here http://confluence.jetbrains.net/display/TCD65/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-AddingorChangingaBuildParameterfromaBuildStep to dynamically update a build parameter, which you can use in the next step. Note, that it won't be available in the step that generates it, only in the next one.

    Note that to set the variable, it must be written out somehow (echo for bash command-line, write-host for Powershell), in quotes. Example:

    echo "##teamcity[setParameter name='env.ENV_AAA' value='aaaaaaaaaa']"
    

    and to use this variable write %env.ENV_AAA% in the box in the next build step (Atleast in TeamCity 9.1.7))

    0 讨论(0)
提交回复
热议问题