mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-04 04:07:16 +02:00
assign library field in logger with respect of containing repository (#968)
* set loggers library entry to repository url * remove comment
This commit is contained in:
parent
5b598e82ce
commit
2bb400910a
@ -9,7 +9,11 @@ RUN go test ./... -cover
|
||||
# execute build
|
||||
# RUN go build -o piper
|
||||
RUN export GIT_COMMIT=$(git rev-parse HEAD) && \
|
||||
go build -ldflags "-X github.com/SAP/jenkins-library/cmd.GitCommit=${GIT_COMMIT}" -o piper
|
||||
export GIT_REPOSITORY=$(git config --get remote.origin.url) && \
|
||||
go build \
|
||||
-ldflags "-X github.com/SAP/jenkins-library/cmd.GitCommit=${GIT_COMMIT}" \
|
||||
-ldflags "-X github.com/SAP/jenkins-library/pkg/log.LibraryRepository=${GIT_REPOSITORY}" \
|
||||
-o piper
|
||||
|
||||
# FROM gcr.io/distroless/base:latest
|
||||
# COPY --from=build-env /build/piper /piper
|
||||
|
@ -4,12 +4,14 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// LibraryRepository that is passed into with -ldflags
|
||||
var LibraryRepository string
|
||||
var logger *logrus.Entry
|
||||
|
||||
// Entry returns the logger entry or creates one if none is present.
|
||||
func Entry() *logrus.Entry {
|
||||
if logger == nil {
|
||||
logger = logrus.WithField("library", "sap/jenkins-library")
|
||||
logger = logrus.WithField("library", LibraryRepository)
|
||||
}
|
||||
return logger
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user