mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
f5c33d51bb
* Change parameter type of nodeExtDescriptorMapping (cherry picked from commitca7ce0485a
) * Remove usage of the depricated ioutil package (cherry picked from commit9821915b33
) * Fix cmd failure if neither git/commitId nor customDescription are provided (cherry picked from commitc362681e45
) * Fix unit test (cherry picked from commit53a90aabb5
) * Step metadata, step code generation * change type of nodeExtDescriptorMapping for export * Refactoring and export implementation * integration test * Add export step * Integration test * format * discard piper.go * Review related changes * restore piper.go * remove unused method * Extend documentation * Add parameter useGoStep to tmsUpload.groovy * Regenerate steps * Rename function * refactor constants * Add error path tests * Move some code to tms package * Move more code to tms * Combine tmsUpload, tmsUtils * Add groovy wrapper * add parameters to groovy step * add import * jenkinsUtils instance * comment namedUser logic in groovy * namedUser param * remove logic for namedUser param * Remove TMS integration tests * discard changes in tmsUpload.groovy * Remove parameters * Restore parameters * Change type of NodeExtDescriptorMapping to map[string]interface{} * tmsUpload: Change type of NodeExtDescriptorMapping to map * Resolve ioutil deprecation * Review related changes * Formatting * Review related improvements * Add tmsUtils test * Formatting tmsUtils_test * Remove parameters from groovy wrapper * Remove tmsUtils_test * Add TMS steps to fieldRelatedWhitelist * Add integration test * Add test to github_actions_integration_test_list.yml * Move test helper method * Step documentation placeholder * Remove parameter StashContent * Restore cmd/integrationArtifactTransport.go --------- Co-authored-by: Oliver Feldmann <oliver.feldmann@sap.com>
60 lines
2.0 KiB
Go
60 lines
2.0 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/SAP/jenkins-library/pkg/log"
|
|
"github.com/SAP/jenkins-library/pkg/telemetry"
|
|
"github.com/SAP/jenkins-library/pkg/tms"
|
|
)
|
|
|
|
func tmsUpload(uploadConfig tmsUploadOptions, telemetryData *telemetry.CustomData, influx *tmsUploadInflux) {
|
|
utils := tms.NewTmsUtils()
|
|
config := convertUploadOptions(uploadConfig)
|
|
communicationInstance := tms.SetupCommunication(config)
|
|
|
|
err := runTmsUpload(uploadConfig, communicationInstance, utils)
|
|
if err != nil {
|
|
log.Entry().WithError(err).Fatal("Failed to run tmsUpload step")
|
|
}
|
|
}
|
|
|
|
func runTmsUpload(uploadConfig tmsUploadOptions, communicationInstance tms.CommunicationInterface, utils tms.TmsUtils) error {
|
|
config := convertUploadOptions(uploadConfig)
|
|
fileId, errUploadFile := tms.UploadFile(config, communicationInstance, utils)
|
|
if errUploadFile != nil {
|
|
return errUploadFile
|
|
}
|
|
|
|
errUploadDescriptors := tms.UploadDescriptors(config, communicationInstance, utils)
|
|
if errUploadDescriptors != nil {
|
|
return errUploadDescriptors
|
|
}
|
|
|
|
_, errUploadFileToNode := communicationInstance.UploadFileToNode(config.NodeName, fileId, config.CustomDescription, config.NamedUser)
|
|
if errUploadFileToNode != nil {
|
|
log.SetErrorCategory(log.ErrorService)
|
|
return fmt.Errorf("failed to upload file to node: %w", errUploadFileToNode)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func convertUploadOptions(uploadConfig tmsUploadOptions) tms.Options {
|
|
var config tms.Options
|
|
config.TmsServiceKey = uploadConfig.TmsServiceKey
|
|
config.CustomDescription = uploadConfig.CustomDescription
|
|
if config.CustomDescription == "" {
|
|
config.CustomDescription = tms.DEFAULT_TR_DESCRIPTION
|
|
}
|
|
config.NamedUser = uploadConfig.NamedUser
|
|
config.NodeName = uploadConfig.NodeName
|
|
config.MtaPath = uploadConfig.MtaPath
|
|
config.MtaVersion = uploadConfig.MtaVersion
|
|
config.NodeExtDescriptorMapping = uploadConfig.NodeExtDescriptorMapping
|
|
config.Proxy = uploadConfig.Proxy
|
|
config.StashContent = uploadConfig.StashContent
|
|
config.Verbose = GeneralConfig.Verbose
|
|
return config
|
|
}
|