Merge pull request #59623 from ixdy/bazel-source-date-epoch

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

bazel: support using SOURCE_DATE_EPOCH to override date

**What this PR does / why we need it**: ports #48708 to apply to the bazel build as well.
Note that bazel already sets `BUILD_TIMESTAMP` using `SOURCE_DATE_EPOCH`, but we have our own timestamp variable, so we need to fix it too.

We could combine this with something like
```shell
SOURCE_DATE_EPOCH=$(git log -1 --format=%cd --date=format:%s)
```
to get closer to repeatable builds. (This uses the timestamp from the last git commit.)

**Release note**:

```release-note
NONE
```

/assign @BenTheElder @mikedanese
This commit is contained in:
Kubernetes Submit Queue 2018-02-08 22:34:29 -08:00 committed by GitHub
commit 05944b1d2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,5 +43,7 @@ gitTreeState ${KUBE_GIT_TREE_STATE-}
gitVersion ${KUBE_GIT_VERSION-}
gitMajor ${KUBE_GIT_MAJOR-}
gitMinor ${KUBE_GIT_MINOR-}
buildDate $(date -u +'%Y-%m-%dT%H:%M:%SZ')
buildDate $(date \
${SOURCE_DATE_EPOCH:+"--date=@${SOURCE_DATE_EPOCH}"} \
-u +'%Y-%m-%dT%H:%M:%SZ')
EOF