未验证 提交 51898452 编写于 作者: LinuxSuRen's avatar LinuxSuRen 提交者: GitHub

Add date as part of version print (#388)

上级 286bf0a0
......@@ -23,6 +23,7 @@ builds:
ldflags:
- -X github.com/jenkins-zh/jenkins-cli/app.version={{.Version}}
- -X github.com/jenkins-zh/jenkins-cli/app.commit={{.ShortCommit}}
- -X github.com/jenkins-zh/jenkins-cli/app.date={{.Date}}
dist: release
archives:
- name_template: "{{ .Binary }}-{{ .Os }}-{{ .Arch }}"
......
......@@ -43,7 +43,8 @@ var versionCmd = &cobra.Command{
version := app.GetVersion()
cmd.Printf("Version: %s\n", version)
cmd.Printf("Commit: %s\n", app.GetCommit())
cmd.Printf("Last Commit: %s\n", app.GetCommit())
cmd.Printf("Build Date: %s\n", app.GetDate())
if rootOptions.Jenkins != "" {
current := getCurrentJenkinsFromOptions()
......
......@@ -7,6 +7,7 @@ import (
var (
version string
commit string
date string
)
// GetVersion returns the version
......@@ -24,6 +25,11 @@ func GetCommit() string {
return commit
}
// GetDate returns the build date time
func GetDate() string {
return date
}
// GetCombinedVersion returns the version and commit id
func GetCombinedVersion() string {
return fmt.Sprintf("jcli; %s; %s", GetVersion(), GetCommit())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册