outposts: include git commit hash in build from git branch

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-12 18:56:44 +02:00
parent e9aa37ba67
commit 37b57ac28f
4 changed files with 8 additions and 1 deletions

View File

@ -117,6 +117,7 @@ stages:
Dockerfile: 'outpost/proxy.Dockerfile' Dockerfile: 'outpost/proxy.Dockerfile'
buildContext: 'outpost/' buildContext: 'outpost/'
tags: "gh-$(branchName)" tags: "gh-$(branchName)"
arguments: '--build-arg GIT_BUILD_HASH=$(Build.SourceVersion)'
- job: ldap_build_docker - job: ldap_build_docker
pool: pool:
vmImage: 'ubuntu-latest' vmImage: 'ubuntu-latest'
@ -142,3 +143,4 @@ stages:
Dockerfile: 'outpost/ldap.Dockerfile' Dockerfile: 'outpost/ldap.Dockerfile'
buildContext: 'outpost/' buildContext: 'outpost/'
tags: "gh-$(branchName)" tags: "gh-$(branchName)"
arguments: '--build-arg GIT_BUILD_HASH=$(Build.SourceVersion)'

View File

@ -1,4 +1,6 @@
FROM golang:1.16.4 AS builder FROM golang:1.16.4 AS builder
ARG GIT_BUILD_HASH
ENV GIT_BUILD_HASH=$GIT_BUILD_HASH
WORKDIR /work WORKDIR /work

View File

@ -33,7 +33,8 @@ func doGlobalSetup(config map[string]interface{}) {
default: default:
log.SetLevel(log.DebugLevel) log.SetLevel(log.DebugLevel)
} }
log.WithField("version", pkg.VERSION).Info("Starting authentik outpost") buildHash := os.Getenv("GIT_BUILD_HASH")
log.WithField("buildHash", buildHash).WithField("version", pkg.VERSION).Info("Starting authentik outpost")
var dsn string var dsn string
if config[ConfigErrorReportingEnabled].(bool) { if config[ConfigErrorReportingEnabled].(bool) {

View File

@ -1,4 +1,6 @@
FROM golang:1.16.4 AS builder FROM golang:1.16.4 AS builder
ARG GIT_BUILD_HASH
ENV GIT_BUILD_HASH=$GIT_BUILD_HASH
WORKDIR /work WORKDIR /work