4

I'm working through my first circleci build using aws-ecr orb and I want my tag to be set dynamically based on the current timestamp. How can I do that?

orbs:
  aws-ecr: circleci/aws-ecr@6.2.0
version: 2.1
workflows:
  # Build and push to ECR on builds to master
  build_and_push_image:
    jobs:
      - aws-ecr/build-and-push-image:
          account-url: AWS_ACCOUNT_URL
          aws-access-key-id: AWS_ACCESS_KEY_ID
          aws-secret-access-key: AWS_SECRET_ACCESS_KEY
          region: AWS_REGION
          repo: node
          tag: <HOW TO SET TAG TO CURRENT DATETIME????>
          filters:
            branches:
              only: master
Catfish
  • 18,876
  • 54
  • 209
  • 353
  • 2
    Is something such as `tag: "some_stuff_$(date +'%Y-%m-%d_%H-%M')_and_stuff"` which should output something like `some_stuff_2019-12-31_12-25_and_stuff` I had a similar issue and use [this tuto](https://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/) for help – Al-un Sep 09 '19 at 08:41

1 Answers1

3

You can append the date using Linux formatting (date +FORMAT).

As user Al-un mentioned above, this is a great reference on how to use those formats.

Here is another user who does something similar.

Axelle
  • 442
  • 1
  • 9
  • 24
  • 2
    Both of those examples show how to fill a date in a shell command. The OP's question is about a CircleCI configuration setting, which is not a shell script – Cheetah Feb 05 '21 at 19:01