TeamCity Current Date variable in MMdd format

前端 未结 8 1408
谎友^
谎友^ 2021-01-31 04:16

In TeamCity is there an easy way to get a variable for the current date in the format MMdd (eg 0811 for 8-Aug)?

My google-fu did not turn up an existing plugins. I look

8条回答
  •  情话喂你
    2021-01-31 04:58

    For Unix based build agents I propose next custom script as one of build commands:

    export current_build_date_format="+%%Y.%%m.%%d"
    export current_build_date="$(date $current_build_date_format)"
    echo "##teamcity[setParameter name='env.current_build_date' value='$current_build_date']"
    

    You have to make double % sign to avoid interpretation for date executable command line argument FORMAT string (see %Y.%m.%d) as already existing TeamCity variable.

提交回复
热议问题