Using timezone in tasks

To use timezone in concourse tasks, 2 conditions must be met:

  • The image used by the concourse task must be timezone-aware
  • The TZ env variable must be set

This is a sample dockerfile for a Ubuntu-based image with timezone awareness:

# oozie/los_angeles
FROM ubuntu
ENV TZ=America/Los_Angeles
RUN apt update && apt install -y tzdata

The following pipeline embeds a task that results in a timezoned output from the date command. The first invocation will display date and time in PST format while the subsequent invocation will produce date and time in UTC.

jobs:
- name: timezoned-task
plan:
- task: tz-aware
config:
platform: linux
image_resource:
type: docker-image
source:
repository: oozie/los_angeles
run:
path: /bin/bash
args:
- -c
- |
date
TZ=UTC date