mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
a46b57e6b4
* Use commonPipelineEnvironment in go binary * Update groovy part incl. tests * Rework structure and naming * Support influx resources in steps * Update tests and some cleanups * Add correct defer handling * Address PR feedback * Fix test * Update resources.go Co-authored-by: Sven Merk <33895725+nevskrem@users.noreply.github.com>
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package cmd
|
|
|
|
import (
|
|
"github.com/SAP/jenkins-library/pkg/config"
|
|
"github.com/SAP/jenkins-library/pkg/log"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
type versionOptions struct {
|
|
}
|
|
|
|
var myVersionOptions versionOptions
|
|
|
|
// 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 {
|
|
log.SetStepName("version")
|
|
log.SetVerbose(GeneralConfig.Verbose)
|
|
return PrepareConfig(cmd, &metadata, "version", &myVersionOptions, config.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
|
|
}
|