1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-07-13 01:30:24 +02:00

fix(golangBuild): keep track of the artifactversion in binary names (#3498)

* fix(golangBuild): keep track of the artifactversion in binary names

* improve the naming scheme
This commit is contained in:
Christian Volk
2022-02-02 17:30:56 +01:00
committed by GitHub
parent 78dac5973b
commit ec783b0da6
4 changed files with 54 additions and 7 deletions

View File

@ -37,6 +37,7 @@ type golangBuildOptions struct {
TestResultFormat string `json:"testResultFormat,omitempty" validate:"possible-values=junit standard"`
PrivateModules string `json:"privateModules,omitempty"`
PrivateModulesGitToken string `json:"privateModulesGitToken,omitempty"`
ArtifactVersion string `json:"artifactVersion,omitempty"`
}
// GolangBuildCommand This step will execute a golang build.
@ -157,6 +158,7 @@ func addGolangBuildFlags(cmd *cobra.Command, stepConfig *golangBuildOptions) {
cmd.Flags().StringVar(&stepConfig.TestResultFormat, "testResultFormat", `junit`, "Defines the output format of the test results.")
cmd.Flags().StringVar(&stepConfig.PrivateModules, "privateModules", os.Getenv("PIPER_privateModules"), "Tells go which modules shall be considered to be private (by setting [GOPRIVATE](https://pkg.go.dev/cmd/go#hdr-Configuration_for_downloading_non_public_code)).")
cmd.Flags().StringVar(&stepConfig.PrivateModulesGitToken, "privateModulesGitToken", os.Getenv("PIPER_privateModulesGitToken"), "GitHub personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line.")
cmd.Flags().StringVar(&stepConfig.ArtifactVersion, "artifactVersion", os.Getenv("PIPER_artifactVersion"), "Version of the artifact to be built.")
cmd.MarkFlagRequired("targetArchitectures")
}
@ -390,6 +392,20 @@ func golangBuildMetadata() config.StepData {
Aliases: []config.Alias{},
Default: os.Getenv("PIPER_privateModulesGitToken"),
},
{
Name: "artifactVersion",
ResourceRef: []config.ResourceReference{
{
Name: "commonPipelineEnvironment",
Param: "artifactVersion",
},
},
Scope: []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
Type: "string",
Mandatory: false,
Aliases: []config.Alias{},
Default: os.Getenv("PIPER_artifactVersion"),
},
},
},
Containers: []config.Container{