Using the percent sign in TeamCity build scripts

前端 未结 3 2422
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 09:33

I am trying to set up a TeamCity build process that runs a custom command line script. The script uses a variable so it needs a percent sign (e.g. %x). But Te

3条回答
  •  醉话见心
    2020-12-03 10:17

    If you want to pass % to TeamCity, you should escape it with other %, i.e. for % it must be %%.

    But windows command line considers % as an escape character, so you should escape it again adding another % before each %, i.e. for %% you should pass %%%%

    Flow is:

    %%%% in cmd -> %% in TeamCity -> % actual sign.
    

    tl;dr: answer to your question will be:

    for /d %%%%x in ("c:\*") do @echo "%%%%x"
    

提交回复
热议问题