VSO(TFS) - get current date time as variable

后端 未结 4 1509
不知归路
不知归路 2020-12-05 13:34

How can I get a current date-time and pass it as a variable to some Deployment task?

4条回答
  •  臣服心动
    2020-12-05 14:12

    For those who use Linux on tfs:

    Define variable

    Make sure it has "Settable at queue time set"

    Create a script in root of your repository

    set-build.date.sh:

    #!/usr/bin/env bash
    DATE=$(date '+%d/%m/%Y %H:%M:%S') 
    echo "##vso[task.setvariable variable=BUILD_DATE;]$DATE"
    

    Other options are listed here.

    Add shell script right after get sources

    Type bash to find this task.

    Done, you can use BUILD_DATE variable in later tasks :)

提交回复
热议问题