2019-10-31 14:57:29 +02:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/SAP/jenkins-library/pkg/config"
|
2019-11-04 15:43:33 +02:00
|
|
|
"github.com/SAP/jenkins-library/pkg/log"
|
2019-10-31 14:57:29 +02:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
type versionOptions struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
var myVersionOptions versionOptions
|
|
|
|
var versionStepConfigJSON string
|
|
|
|
|
|
|
|
// VersionCommand Returns the version of the piper binary
|
|
|
|
func VersionCommand() *cobra.Command {
|
|
|
|
metadata := versionMetadata()
|
|
|
|
var createVersionCmd = &cobra.Command{
|
|
|
|
Use: "version",
|
|
|
|
Short: "Returns the version of the piper binary",
|
|
|
|
Long: `Writes the commit hash and the tag (if any) to stdout and exits with 0.`,
|
|
|
|
PreRunE: func(cmd *cobra.Command, args []string) error {
|
2019-11-04 15:43:33 +02:00
|
|
|
log.SetStepName("version")
|
2019-11-06 15:07:41 +02:00
|
|
|
log.SetVerbose(GeneralConfig.verbose)
|
2019-10-31 14:57:29 +02:00
|
|
|
return PrepareConfig(cmd, &metadata, "version", &myVersionOptions, openPiperFile)
|
|
|
|
},
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
return version(myVersionOptions)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
addVersionFlags(createVersionCmd)
|
|
|
|
return createVersionCmd
|
|
|
|
}
|
|
|
|
|
|
|
|
func addVersionFlags(cmd *cobra.Command) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// retrieve step metadata
|
|
|
|
func versionMetadata() config.StepData {
|
|
|
|
var theMetaData = config.StepData{
|
|
|
|
Spec: config.StepSpec{
|
|
|
|
Inputs: config.StepInputs{
|
|
|
|
Parameters: []config.StepParameters{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return theMetaData
|
|
|
|
}
|