i am trying to define timestamp as a global variable but it doesn’t seem to work. When i try to echo the time stamp value i get $(date +%Y-%m-%d-%H-%M) instead of the date and time value. I want to be able to get something like this when i echo out. 2022-07-20-23-24
version: 0.2
env:
variables:
TIMESTAMP: $(date +%Y-%m-%d-%H-%M)
parameter-store:
USERNAME: "username"
PASSWORD: "secret"
Phases:
install:
runtime-version:
python:3.8
pre_build:
commands:
- echo '$TIMESTAMP'
build:
commands:
- echo '$TIMESTAMP'
2
Answers
The only way I know of to make it work, is by saving timestamp in a tmp file. For example:
Try setting the variable during the install phase.
echo-datetime.sh
buildspec.yml
Partial log from CodeBuild