Skip to main content
added 78 characters in body
Source Link
Youngjae
  • 24.8k
  • 19
  • 116
  • 201

If you only want to have one-line bash command in a build step, just use as below.

echo "##teamcity[setParameter name='build.timestamp' value='$(date +%m%d+%%m%%d)']"

(double % symbol is for TeamCity own escape rule to use % character)

It will set a MMdd parameter value right after the execution during runtime so very useful to put at any build step. Then, you can retrieve a parameter value afterward.

Note that you should create build.timestamp parameter firstly to TeamCity project.

A step further, I made a simple bash script to have bash date format timestamp. This script will set timestamp to whatever bash supported datetime format and parameter name to TeamCity.

name=""  # TeamCity parameter name
format="%Y-%m-%dT%H:%M:%S%z"  # ISO8601 format by default
result=""  # a TeamCity parameter value to be set

for ARGUMENT in "$@"
do
    KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
    VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)

    case "$KEY" in
            name)              name=${VALUE} ;;
            format)     format=${VALUE} ;;
            *)
    esac
done

result=$(date "+$format")

echo "##teamcity[setParameter name='$name' value='$result']"

Below usage will set ISO8601 format timestamp to build.timestamp parameter.

./teamcity_datetime.sh name=build.timestamp

If you want to set only MMdd, the execution could be as below.

./teamcity_datetime.sh name=build.timestamp format="%m%d"format="%%m%%d"

If you only want to have one-line bash command in a build step, just use as below.

echo "##teamcity[setParameter name='build.timestamp' value='$(date +%m%d)']"

It will set a MMdd parameter value right after the execution during runtime so very useful to put at any build step. Then, you can retrieve a parameter value afterward.

Note that you should create build.timestamp parameter firstly to TeamCity project.

A step further, I made a simple bash script to have bash date format timestamp. This script will set timestamp to whatever bash supported datetime format and parameter name to TeamCity.

name=""  # TeamCity parameter name
format="%Y-%m-%dT%H:%M:%S%z"  # ISO8601 format by default
result=""  # a TeamCity parameter value to be set

for ARGUMENT in "$@"
do
    KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
    VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)

    case "$KEY" in
            name)              name=${VALUE} ;;
            format)     format=${VALUE} ;;
            *)
    esac
done

result=$(date "+$format")

echo "##teamcity[setParameter name='$name' value='$result']"

Below usage will set ISO8601 format timestamp to build.timestamp parameter.

./teamcity_datetime.sh name=build.timestamp

If you want to set only MMdd, the execution could be as below.

./teamcity_datetime.sh name=build.timestamp format="%m%d"

If you only want to have one-line bash command in a build step, just use as below.

echo "##teamcity[setParameter name='build.timestamp' value='$(date +%%m%%d)']"

(double % symbol is for TeamCity own escape rule to use % character)

It will set a MMdd parameter value right after the execution during runtime so very useful to put at any build step. Then, you can retrieve a parameter value afterward.

Note that you should create build.timestamp parameter firstly to TeamCity project.

A step further, I made a simple bash script to have bash date format timestamp. This script will set timestamp to whatever bash supported datetime format and parameter name to TeamCity.

name=""  # TeamCity parameter name
format="%Y-%m-%dT%H:%M:%S%z"  # ISO8601 format by default
result=""  # a TeamCity parameter value to be set

for ARGUMENT in "$@"
do
    KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
    VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)

    case "$KEY" in
            name)              name=${VALUE} ;;
            format)     format=${VALUE} ;;
            *)
    esac
done

result=$(date "+$format")

echo "##teamcity[setParameter name='$name' value='$result']"

Below usage will set ISO8601 format timestamp to build.timestamp parameter.

./teamcity_datetime.sh name=build.timestamp

If you want to set only MMdd, the execution could be as below.

./teamcity_datetime.sh name=build.timestamp format="%%m%%d"
deleted 5 characters in body
Source Link
Youngjae
  • 24.8k
  • 19
  • 116
  • 201

If you only want to have one-line bash command in a build step, just use as below.

echo "##teamcity[setParameter name='build.timestamp' value='$(date +%m%d)']"

It will set a MMdd parameter value right after the execution during runtime so very useful to put at any build step. Then, you can retrieve a parameter value afterward.

Note that you should create build.timestamp parameter firstly to TeamCity project.

A step further, I made a simple bash script to have bash date format timestamp. This script will set timestamp to whatever bash supported datetime format and parameter name to TeamCity.

name=""  # TeamCity parameter name
format="%Y-%m-%dT%H:%M:%S%z"  # ISO8601 format by default
result=""  # a TeamCity parameter value to be set

for ARGUMENT in "$@"
do
    KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
    VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)

    case "$KEY" in
            name)              name=${VALUE} ;;
            format)     format=${VALUE} ;;
            *)
    esac
done

result=$(date "+$format")

echo "##teamcity[setParameter name='$name' value='$result']"

Below usage will makeset ISO8601 format timestamp to build.timestamp parameter.

./teamcity_datetime.sh name=build.timestamp

If you want to set only MMdd, the execution could be as below.

./teamcity_datetime.sh name=build.timestamp format="%m%d"

If you only want to have one-line bash command in a build step, just use as below.

echo "##teamcity[setParameter name='build.timestamp' value='$(date +%m%d)']"

It will set a MMdd parameter value right after the execution during runtime so very useful to put at any build step.

Note that you should create build.timestamp parameter firstly to TeamCity project.

A step further, I made a simple bash script to have bash date format timestamp. This script will set timestamp to whatever bash supported datetime format and parameter name to TeamCity.

name=""  # TeamCity parameter name
format="%Y-%m-%dT%H:%M:%S%z"  # ISO8601 format by default
result=""  # a TeamCity parameter value to be set

for ARGUMENT in "$@"
do
    KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
    VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)

    case "$KEY" in
            name)              name=${VALUE} ;;
            format)     format=${VALUE} ;;
            *)
    esac
done

result=$(date "+$format")

echo "##teamcity[setParameter name='$name' value='$result']"

Below usage will make ISO8601 format to build.timestamp parameter.

./teamcity_datetime.sh name=build.timestamp

If you want to set only MMdd, the execution could be as below.

./teamcity_datetime.sh name=build.timestamp format="%m%d"

If you only want to have one-line bash command in a build step, just use as below.

echo "##teamcity[setParameter name='build.timestamp' value='$(date +%m%d)']"

It will set a MMdd parameter value right after the execution during runtime so very useful to put at any build step. Then, you can retrieve a parameter value afterward.

Note that you should create build.timestamp parameter firstly to TeamCity project.

A step further, I made a simple bash script to have bash date format timestamp. This script will set timestamp to whatever bash supported datetime format and parameter name to TeamCity.

name=""  # TeamCity parameter name
format="%Y-%m-%dT%H:%M:%S%z"  # ISO8601 format by default
result=""  # a TeamCity parameter value to be set

for ARGUMENT in "$@"
do
    KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
    VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)

    case "$KEY" in
            name)              name=${VALUE} ;;
            format)     format=${VALUE} ;;
            *)
    esac
done

result=$(date "+$format")

echo "##teamcity[setParameter name='$name' value='$result']"

Below usage will set ISO8601 format timestamp to build.timestamp parameter.

./teamcity_datetime.sh name=build.timestamp

If you want to set only MMdd, the execution could be as below.

./teamcity_datetime.sh name=build.timestamp format="%m%d"
deleted 5 characters in body
Source Link
Youngjae
  • 24.8k
  • 19
  • 116
  • 201

If you only want to have one-line executionbash command in a build step, just use as below.

echo "##teamcity[setParameter name='build.timestamp' value='$(date +%Y-%m-%dT%H:%M:%S%z+%m%d)']"

It will set a MMdd parameter value right after the execution during runtime so very useful to put at any build step.

Note that you should create build.timestamp parameter firstly to TeamCity project.

A step further, I made a simple bash script to have bash date format timestamp. This script will set timestamp to whatever bash supported datetime format and parameter name to TeamCity.

name=""  # TeamCity parameter name
format="%Y-%m-%dT%H:%M:%S%z"  # ISO8601 format by default
result=""  # a TeamCity parameter value to be set

for ARGUMENT in "$@"
do
    KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
    VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)

    case "$KEY" in
            name)              name=${VALUE} ;;
            format)     format=${VALUE} ;;
            *)
    esac
done

result=$(date "+$format")

echo "##teamcity[setParameter name='$name' value='$result']"

Below usage will make ISO8601 format to build.timestamp parameter.

./teamcity_datetime.sh name=build.timestamp

If you want to set only YYYY-MM-DDMMdd, bash has %F formatthe execution could be as below.

./teamcity_datetime.sh name=build.timestamp format="%F"format="%m%d"

If you only want to have one-line execution in a build step, just use as below.

echo "##teamcity[setParameter name='build.timestamp' value='$(date +%Y-%m-%dT%H:%M:%S%z)']"

It will set a parameter right after the execution during runtime so very useful to put at any build step.

Note that you should create build.timestamp parameter firstly to TeamCity project.

A step further, I made a simple bash script to have bash date format timestamp. This script will set timestamp to whatever bash supported datetime format and parameter name to TeamCity.

name=""  # TeamCity parameter name
format="%Y-%m-%dT%H:%M:%S%z"  # ISO8601 format by default
result=""  # a TeamCity parameter value to be set

for ARGUMENT in "$@"
do
    KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
    VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)

    case "$KEY" in
            name)              name=${VALUE} ;;
            format)     format=${VALUE} ;;
            *)
    esac
done

result=$(date "+$format")

echo "##teamcity[setParameter name='$name' value='$result']"

Below usage will make ISO8601 format to build.timestamp parameter.

./teamcity_datetime.sh name=build.timestamp

If you want to set only YYYY-MM-DD, bash has %F format.

./teamcity_datetime.sh name=build.timestamp format="%F"

If you only want to have one-line bash command in a build step, just use as below.

echo "##teamcity[setParameter name='build.timestamp' value='$(date +%m%d)']"

It will set a MMdd parameter value right after the execution during runtime so very useful to put at any build step.

Note that you should create build.timestamp parameter firstly to TeamCity project.

A step further, I made a simple bash script to have bash date format timestamp. This script will set timestamp to whatever bash supported datetime format and parameter name to TeamCity.

name=""  # TeamCity parameter name
format="%Y-%m-%dT%H:%M:%S%z"  # ISO8601 format by default
result=""  # a TeamCity parameter value to be set

for ARGUMENT in "$@"
do
    KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
    VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)

    case "$KEY" in
            name)              name=${VALUE} ;;
            format)     format=${VALUE} ;;
            *)
    esac
done

result=$(date "+$format")

echo "##teamcity[setParameter name='$name' value='$result']"

Below usage will make ISO8601 format to build.timestamp parameter.

./teamcity_datetime.sh name=build.timestamp

If you want to set only MMdd, the execution could be as below.

./teamcity_datetime.sh name=build.timestamp format="%m%d"
Source Link
Youngjae
  • 24.8k
  • 19
  • 116
  • 201
Loading