You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-07-15 01:34:38 +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:
committed by
GitHub
parent
5b598e82ce
commit
2bb400910a
@ -9,7 +9,11 @@ RUN go test ./... -cover
|
|||||||
# execute build
|
# execute build
|
||||||
# RUN go build -o piper
|
# RUN go build -o piper
|
||||||
RUN export GIT_COMMIT=$(git rev-parse HEAD) && \
|
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
|
# FROM gcr.io/distroless/base:latest
|
||||||
# COPY --from=build-env /build/piper /piper
|
# COPY --from=build-env /build/piper /piper
|
||||||
|
@ -4,12 +4,14 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// LibraryRepository that is passed into with -ldflags
|
||||||
|
var LibraryRepository string
|
||||||
var logger *logrus.Entry
|
var logger *logrus.Entry
|
||||||
|
|
||||||
// Entry returns the logger entry or creates one if none is present.
|
// Entry returns the logger entry or creates one if none is present.
|
||||||
func Entry() *logrus.Entry {
|
func Entry() *logrus.Entry {
|
||||||
if logger == nil {
|
if logger == nil {
|
||||||
logger = logrus.WithField("library", "sap/jenkins-library")
|
logger = logrus.WithField("library", LibraryRepository)
|
||||||
}
|
}
|
||||||
return logger
|
return logger
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user