Browse Source

添加版本信息

dev
yfh 6 months ago
parent
commit
f10171ffbd
  1. 4
      build/Dockerfile
  2. 4
      build/jenkinsfile_image_app
  3. 21
      containerApp/main.go

4
build/Dockerfile

@ -9,7 +9,9 @@ RUN pwd \
&& go env -w GO111MODULE=on
RUN cd containerApp \
&& CGO_ENABLED=0 go build -a -v -o ./app.exe main.go
&& CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build \
-ldflags "-extldflags -static -X main.VERSION=$VERSION -X main.SVN_REVISION=$SVN_REVISION -X main.BUILD_NUMBER=$BUILD_NUMBER -X main.BUILD_TIME=$BUILD_TIME -X main.GO_VERSION=$GO_VERSION" \
-tags "et-go" -a -v -o ./app.exe main.go
FROM registry.ngaiot.com/base-images/golang-1.22:1.22-fs-3
WORKDIR /app/

4
build/jenkinsfile_image_app

@ -16,8 +16,10 @@ podTemplate {
go env -w GO111MODULE=on
go env -w GOPRIVATE=gitea.ngaiot.com,gitea.anxinyun.cn
go env -w GOSUMDB=sum.golang.org
go env -w GOOS=linux
go env -w GOARCH=arm64
go env
go build -a -v -o app.exe containerApp/main.go
go build -ldflags "-extldflags -static -X main.VERSION=$VERSION -X main.SVN_REVISION=$SVN_REVISION -X main.BUILD_NUMBER=$BUILD_NUMBER -X main.BUILD_TIME=$BUILD_TIME -X main.GO_VERSION=$GO_VERSION" -tags="et-go" -a -v -o app.exe containerApp/main.go
tar -cvf app.tar *.exe *.yaml
'''
}

21
containerApp/main.go

@ -8,9 +8,30 @@ import (
_ "net/http/pprof"
etNode "node/app"
"os"
"runtime"
)
var (
VERSION string
SVN_REVISION string
BUILD_NUMBER string
BUILD_TIME string
GO_VERSION string
)
func logVersions() {
log.Printf("Version:%s", VERSION)
log.Printf("SVN Revision:%s", SVN_REVISION)
log.Printf("Build Number:%s", BUILD_NUMBER)
log.Printf("Build Time:%s", BUILD_TIME)
log.Printf("Go Version:%s", GO_VERSION)
log.Printf("Go OS/Arch:%s/%s", runtime.GOOS, runtime.GOARCH)
log.Println()
}
func main() {
logVersions()
//获取状态集合序号
hostName, err := os.Hostname() //"etgo-0"
if err != nil {

Loading…
Cancel
Save