You've already forked sap-jenkins-library
							
							
				mirror of
				https://github.com/SAP/jenkins-library.git
				synced 2025-10-30 23:57:50 +02:00 
			
		
		
		
	fix(helmExecute): respect version from Chart (#3780)
* fix(helmExecute): respect version from Chart using version from CPE can create failure situations in case format is not semver. This is the case for maven artifacts, for example. * chore: simplify condition * chore: cleanup * chore: cleanup
This commit is contained in:
		| @@ -29,8 +29,8 @@ func helmExecute(config helmExecuteOptions, telemetryData *telemetry.CustomData) | ||||
| 		TargetRepositoryPassword:  config.TargetRepositoryPassword, | ||||
| 		HelmCommand:               config.HelmCommand, | ||||
| 		CustomTLSCertificateLinks: config.CustomTLSCertificateLinks, | ||||
| 		// ArtifactVersion:           config.Version, | ||||
| 		Version: config.Version, | ||||
| 		Version:                   config.Version, | ||||
| 		PublishVersion:            config.Version, | ||||
| 	} | ||||
|  | ||||
| 	utils := kubernetes.NewDeployUtilsBundle(helmConfig.CustomTLSCertificateLinks) | ||||
| @@ -47,8 +47,8 @@ func helmExecute(config helmExecuteOptions, telemetryData *telemetry.CustomData) | ||||
|  | ||||
| 	helmConfig.DeploymentName = artifactInfo.ArtifactID | ||||
|  | ||||
| 	if len(config.Version) == 0 { | ||||
| 		helmConfig.Version = artifactInfo.Version | ||||
| 	if len(helmConfig.PublishVersion) == 0 { | ||||
| 		helmConfig.PublishVersion = artifactInfo.Version | ||||
| 	} | ||||
|  | ||||
| 	helmExecutor := kubernetes.NewHelmExecutor(helmConfig, utils, GeneralConfig.Verbose, log.Writer()) | ||||
|   | ||||
| @@ -456,18 +456,13 @@ func helmExecuteMetadata() config.StepData { | ||||
| 						Default:     false, | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name: "version", | ||||
| 						ResourceRef: []config.ResourceReference{ | ||||
| 							{ | ||||
| 								Name:  "commonPipelineEnvironment", | ||||
| 								Param: "artifactVersion", | ||||
| 							}, | ||||
| 						}, | ||||
| 						Scope:     []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:      "string", | ||||
| 						Mandatory: false, | ||||
| 						Aliases:   []config.Alias{}, | ||||
| 						Default:   os.Getenv("PIPER_version"), | ||||
| 						Name:        "version", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   false, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_version"), | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
|   | ||||
| @@ -45,6 +45,7 @@ type HelmExecuteOptions struct { | ||||
| 	DockerConfigJSON          string   `json:"dockerConfigJSON,omitempty"` | ||||
| 	Version                   string   `json:"version,omitempty"` | ||||
| 	AppVersion                string   `json:"appVersion,omitempty"` | ||||
| 	PublishVersion            string   `json:"publishVersion,omitempty"` | ||||
| 	Dependency                string   `json:"dependency,omitempty" validate:"possible-values=build list update"` | ||||
| 	PackageDependencyUpdate   bool     `json:"packageDependencyUpdate,omitempty"` | ||||
| 	DumpLogs                  bool     `json:"dumpLogs,omitempty"` | ||||
| @@ -399,7 +400,7 @@ func (h *HelmExecute) RunHelmPublish() error { | ||||
|  | ||||
| 	h.utils.SetOptions(repoClientOptions) | ||||
|  | ||||
| 	binary := fmt.Sprintf("%v", h.config.DeploymentName+"-"+h.config.Version+".tgz") | ||||
| 	binary := fmt.Sprintf("%v", h.config.DeploymentName+"-"+h.config.PublishVersion+".tgz") | ||||
|  | ||||
| 	targetPath := fmt.Sprintf("%v/%s", h.config.DeploymentName, binary) | ||||
|  | ||||
|   | ||||
| @@ -443,7 +443,7 @@ func TestRunHelm(t *testing.T) { | ||||
| 			TargetRepositoryURL:      "https://my.target.repository.local/", | ||||
| 			TargetRepositoryUser:     "testUser", | ||||
| 			TargetRepositoryPassword: "testPWD", | ||||
| 			Version:                  "1.2.3", | ||||
| 			PublishVersion:           "1.2.3", | ||||
| 			DeploymentName:           "test_helm_chart", | ||||
| 			ChartPath:                ".", | ||||
| 		} | ||||
|   | ||||
| @@ -268,9 +268,6 @@ spec: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         resourceRef: | ||||
|           - name: commonPipelineEnvironment | ||||
|             param: artifactVersion | ||||
|   containers: | ||||
|     - image: dtzar/helm-kubectl:3.8.0 | ||||
|       workingDir: /config | ||||
|   | ||||
		Reference in New Issue
	
	Block a user