1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-25 21:39:13 +02:00

Allow cALM service key for cTMS steps (#4661)

* Allow cALM service keys

* Fix typo

Co-authored-by: Srinikitha Kondreddy <srinikitha.kondreddy@sap.com>

* fix typo

Co-authored-by: Srinikitha Kondreddy <srinikitha.kondreddy@sap.com>

* Hardcode tms endpoint in calm test case

* Add new serviceKey parameter

* Use new serviceKey parameter

With deprecation warning if old tmsServiceKey parameter is used

* Add unit tests and optimise

* Remove tms from service key log message

* Apply suggestions from code review

Co-authored-by: Artem Bannikov <62880541+artembannikov@users.noreply.github.com>

* Remove unused json fields mapping

* Apply review suggestion

* Apply further review suggestions

* Use new parameter name in groovy

* Generate again

* Fix groovy test

---------

Co-authored-by: Srinikitha Kondreddy <srinikitha.kondreddy@sap.com>
Co-authored-by: Artem Bannikov <62880541+artembannikov@users.noreply.github.com>
This commit is contained in:
Oliver Feldmann 2023-11-27 14:28:18 +01:00 committed by GitHub
parent c6c02fc31d
commit 17de9ed34c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 263 additions and 40 deletions

View File

@ -49,7 +49,11 @@ func runTmsExport(exportConfig tmsExportOptions, communicationInstance tms.Commu
func convertExportOptions(exportConfig tmsExportOptions) tms.Options {
var config tms.Options
config.TmsServiceKey = exportConfig.TmsServiceKey
config.ServiceKey = exportConfig.ServiceKey
if exportConfig.ServiceKey == "" && exportConfig.TmsServiceKey != "" {
config.ServiceKey = exportConfig.TmsServiceKey
log.Entry().Warn("DEPRECATION WARNING: The tmsServiceKey parameter has been deprecated, please use the serviceKey parameter instead.")
}
config.CustomDescription = exportConfig.CustomDescription
if config.CustomDescription == "" {
config.CustomDescription = tms.DEFAULT_TR_DESCRIPTION

View File

@ -19,6 +19,7 @@ import (
type tmsExportOptions struct {
TmsServiceKey string `json:"tmsServiceKey,omitempty"`
ServiceKey string `json:"serviceKey,omitempty"`
CustomDescription string `json:"customDescription,omitempty"`
NamedUser string `json:"namedUser,omitempty"`
NodeName string `json:"nodeName,omitempty"`
@ -83,7 +84,7 @@ For more information, see [official documentation of SAP Cloud Transport Managem
!!! note "Prerequisites"
* You have subscribed to and set up TMS, as described in [Initial Setup](https://help.sap.com/viewer/7f7160ec0d8546c6b3eab72fb5ad6fd8/Cloud/en-US/66fd7283c62f48adb23c56fb48c84a60.html), which includes the configuration of your transport landscape.
* A corresponding service key has been created, as described in [Set Up the Environment to Transport Content Archives directly in an Application](https://help.sap.com/viewer/7f7160ec0d8546c6b3eab72fb5ad6fd8/Cloud/en-US/8d9490792ed14f1bbf8a6ac08a6bca64.html). This service key (JSON) must be stored as a secret text within the Jenkins secure store or provided as value of tmsServiceKey parameter.`,
* A corresponding service key has been created, as described in [Set Up the Environment to Transport Content Archives directly in an Application](https://help.sap.com/viewer/7f7160ec0d8546c6b3eab72fb5ad6fd8/Cloud/en-US/8d9490792ed14f1bbf8a6ac08a6bca64.html). This service key (JSON) must be stored as a secret text within the Jenkins secure store or provided as value of serviceKey parameter.`,
PreRunE: func(cmd *cobra.Command, _ []string) error {
startTime = time.Now()
log.SetStepName(STEP_NAME)
@ -101,6 +102,7 @@ For more information, see [official documentation of SAP Cloud Transport Managem
return err
}
log.RegisterSecret(stepConfig.TmsServiceKey)
log.RegisterSecret(stepConfig.ServiceKey)
if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 {
sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID)
@ -170,7 +172,8 @@ For more information, see [official documentation of SAP Cloud Transport Managem
}
func addTmsExportFlags(cmd *cobra.Command, stepConfig *tmsExportOptions) {
cmd.Flags().StringVar(&stepConfig.TmsServiceKey, "tmsServiceKey", os.Getenv("PIPER_tmsServiceKey"), "Service key JSON string to access the SAP Cloud Transport Management service instance APIs. If not specified and if pipeline is running on Jenkins, service key, stored under ID provided with credentialsId parameter, is used.")
cmd.Flags().StringVar(&stepConfig.TmsServiceKey, "tmsServiceKey", os.Getenv("PIPER_tmsServiceKey"), "DEPRECATION WARNING: This parameter has been deprecated, please use the serviceKey parameter instead, which supports both service key for TMS (SAP Cloud Transport Management service), as well as service key for CALM (SAP Cloud Application Lifecycle Management) service.\nService key JSON string to access the SAP Cloud Transport Management service instance APIs.\n")
cmd.Flags().StringVar(&stepConfig.ServiceKey, "serviceKey", os.Getenv("PIPER_serviceKey"), "Service key JSON string to access TMS (SAP Cloud Transport Management service) instance APIs. This can be a service key for TMS, or a service key for CALM (SAP Cloud Application Lifecycle Management) service. If not specified and if pipeline is running on Jenkins, service key, stored under ID provided with credentialsId parameter, is used.\n")
cmd.Flags().StringVar(&stepConfig.CustomDescription, "customDescription", os.Getenv("PIPER_customDescription"), "Can be used as the description of a transport request. Will overwrite the default, which is corresponding Git commit ID.")
cmd.Flags().StringVar(&stepConfig.NamedUser, "namedUser", `Piper-Pipeline`, "Defines the named user to execute transport request with. The default value is 'Piper-Pipeline'. If pipeline is running on Jenkins, the name of the user, who started the job, is tried to be used at first.")
cmd.Flags().StringVar(&stepConfig.NodeName, "nodeName", os.Getenv("PIPER_nodeName"), "Defines the name of the export node - starting node in TMS landscape. The transport request is added to the queues of the follow-on nodes of export node.")
@ -179,7 +182,7 @@ func addTmsExportFlags(cmd *cobra.Command, stepConfig *tmsExportOptions) {
cmd.Flags().StringVar(&stepConfig.Proxy, "proxy", os.Getenv("PIPER_proxy"), "Proxy URL which should be used for communication with the SAP Cloud Transport Management service backend.")
cmd.MarkFlagRequired("tmsServiceKey")
cmd.MarkFlagRequired("serviceKey")
cmd.MarkFlagRequired("nodeName")
}
@ -194,18 +197,27 @@ func tmsExportMetadata() config.StepData {
Spec: config.StepSpec{
Inputs: config.StepInputs{
Secrets: []config.StepSecrets{
{Name: "credentialsId", Description: "Jenkins 'Secret text' credentials ID containing service key for SAP Cloud Transport Management service.", Type: "jenkins"},
{Name: "credentialsId", Description: "Jenkins 'Secret text' credentials ID containing service key for TMS (SAP Cloud Transport Management service) or CALM (SAP Cloud Application Lifecycle Management) service.", Type: "jenkins"},
},
Resources: []config.StepResources{
{Name: "buildResult", Type: "stash"},
},
Parameters: []config.StepParameters{
{
Name: "tmsServiceKey",
Name: "tmsServiceKey",
ResourceRef: []config.ResourceReference{},
Scope: []string{"PARAMETERS", "STEPS", "STAGES"},
Type: "string",
Mandatory: false,
Aliases: []config.Alias{},
Default: os.Getenv("PIPER_tmsServiceKey"),
},
{
Name: "serviceKey",
ResourceRef: []config.ResourceReference{
{
Name: "credentialsId",
Param: "tmsServiceKey",
Param: "serviceKey",
Type: "secret",
},
},
@ -213,7 +225,7 @@ func tmsExportMetadata() config.StepData {
Type: "string",
Mandatory: true,
Aliases: []config.Alias{},
Default: os.Getenv("PIPER_tmsServiceKey"),
Default: os.Getenv("PIPER_serviceKey"),
},
{
Name: "customDescription",

View File

@ -150,3 +150,50 @@ func TestRunTmsExport(t *testing.T) {
assert.EqualError(t, err, "failed to export file to node: Something went wrong on exporting file to node")
})
}
func Test_convertExportOptions(t *testing.T) {
t.Parallel()
mockServiceKey := `no real serviceKey json necessary for these tests`
t.Run("Use of new serviceKey parameter works", func(t *testing.T) {
t.Parallel()
// init
config := tmsExportOptions{ServiceKey: mockServiceKey}
wantOptions := tms.Options{ServiceKey: mockServiceKey, CustomDescription: "Created by Piper"}
// test
gotOptions := convertExportOptions(config)
// assert
assert.Equal(t, wantOptions, gotOptions)
})
t.Run("Use of old tmsServiceKey parameter works as well", func(t *testing.T) {
t.Parallel()
// init
config := tmsExportOptions{TmsServiceKey: mockServiceKey}
wantOptions := tms.Options{ServiceKey: mockServiceKey, CustomDescription: "Created by Piper"}
// test
gotOptions := convertExportOptions(config)
// assert
assert.Equal(t, wantOptions, gotOptions)
})
t.Run("Use of both tmsServiceKey and serviceKey parameter favors the new serviceKey parameter", func(t *testing.T) {
t.Parallel()
// init
config := tmsExportOptions{ServiceKey: mockServiceKey, TmsServiceKey: "some other string"}
wantOptions := tms.Options{ServiceKey: mockServiceKey, CustomDescription: "Created by Piper"}
// test
gotOptions := convertExportOptions(config)
// assert
assert.Equal(t, wantOptions, gotOptions)
})
}

View File

@ -42,7 +42,11 @@ func runTmsUpload(uploadConfig tmsUploadOptions, communicationInstance tms.Commu
func convertUploadOptions(uploadConfig tmsUploadOptions) tms.Options {
var config tms.Options
config.TmsServiceKey = uploadConfig.TmsServiceKey
config.ServiceKey = uploadConfig.ServiceKey
if uploadConfig.ServiceKey == "" && uploadConfig.TmsServiceKey != "" {
config.ServiceKey = uploadConfig.TmsServiceKey
log.Entry().Warn("DEPRECATION WARNING: The tmsServiceKey parameter has been deprecated, please use the serviceKey parameter instead.")
}
config.CustomDescription = uploadConfig.CustomDescription
if config.CustomDescription == "" {
config.CustomDescription = tms.DEFAULT_TR_DESCRIPTION

View File

@ -19,6 +19,7 @@ import (
type tmsUploadOptions struct {
TmsServiceKey string `json:"tmsServiceKey,omitempty"`
ServiceKey string `json:"serviceKey,omitempty"`
CustomDescription string `json:"customDescription,omitempty"`
NamedUser string `json:"namedUser,omitempty"`
NodeName string `json:"nodeName,omitempty"`
@ -84,7 +85,7 @@ For more information, see [official documentation of SAP Cloud Transport Managem
!!! note "Prerequisites"
* You have subscribed to and set up TMS, as described in [Initial Setup](https://help.sap.com/viewer/7f7160ec0d8546c6b3eab72fb5ad6fd8/Cloud/en-US/66fd7283c62f48adb23c56fb48c84a60.html), which includes the configuration of a node to be used for uploading an MTA file.
* A corresponding service key has been created, as described in [Set Up the Environment to Transport Content Archives directly in an Application](https://help.sap.com/viewer/7f7160ec0d8546c6b3eab72fb5ad6fd8/Cloud/en-US/8d9490792ed14f1bbf8a6ac08a6bca64.html). This service key (JSON) must be stored as a secret text within the Jenkins secure store or provided as value of tmsServiceKey parameter.`,
* A corresponding service key has been created, as described in [Set Up the Environment to Transport Content Archives directly in an Application](https://help.sap.com/viewer/7f7160ec0d8546c6b3eab72fb5ad6fd8/Cloud/en-US/8d9490792ed14f1bbf8a6ac08a6bca64.html). This service key (JSON) must be stored as a secret text within the Jenkins secure store or provided as value of serviceKey parameter.`,
PreRunE: func(cmd *cobra.Command, _ []string) error {
startTime = time.Now()
log.SetStepName(STEP_NAME)
@ -102,6 +103,7 @@ For more information, see [official documentation of SAP Cloud Transport Managem
return err
}
log.RegisterSecret(stepConfig.TmsServiceKey)
log.RegisterSecret(stepConfig.ServiceKey)
if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 {
sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID)
@ -171,7 +173,8 @@ For more information, see [official documentation of SAP Cloud Transport Managem
}
func addTmsUploadFlags(cmd *cobra.Command, stepConfig *tmsUploadOptions) {
cmd.Flags().StringVar(&stepConfig.TmsServiceKey, "tmsServiceKey", os.Getenv("PIPER_tmsServiceKey"), "Service key JSON string to access the SAP Cloud Transport Management service instance APIs. If not specified and if pipeline is running on Jenkins, service key, stored under ID provided with credentialsId parameter, is used.")
cmd.Flags().StringVar(&stepConfig.TmsServiceKey, "tmsServiceKey", os.Getenv("PIPER_tmsServiceKey"), "DEPRECATION WARNING: This parameter has been deprecated, please use the serviceKey parameter instead, which supports both service key for TMS (SAP Cloud Transport Management service), as well as service key for CALM (SAP Cloud Application Lifecycle Management) service.\nService key JSON string to access the SAP Cloud Transport Management service instance APIs.\n")
cmd.Flags().StringVar(&stepConfig.ServiceKey, "serviceKey", os.Getenv("PIPER_serviceKey"), "Service key JSON string to access TMS (SAP Cloud Transport Management service) instance APIs. This can be a service key for TMS, or a service key for CALM (SAP Cloud Application Lifecycle Management) service. If not specified and if pipeline is running on Jenkins, service key, stored under ID provided with credentialsId parameter, is used.\n")
cmd.Flags().StringVar(&stepConfig.CustomDescription, "customDescription", os.Getenv("PIPER_customDescription"), "Can be used as the description of a transport request. Will overwrite the default, which is corresponding Git commit ID.")
cmd.Flags().StringVar(&stepConfig.NamedUser, "namedUser", `Piper-Pipeline`, "Defines the named user to execute transport request with. The default value is 'Piper-Pipeline'. If pipeline is running on Jenkins, the name of the user, who started the job, is tried to be used at first.")
cmd.Flags().StringVar(&stepConfig.NodeName, "nodeName", os.Getenv("PIPER_nodeName"), "Defines the name of the node to which the *.mtar file should be uploaded.")
@ -181,7 +184,7 @@ func addTmsUploadFlags(cmd *cobra.Command, stepConfig *tmsUploadOptions) {
cmd.Flags().StringVar(&stepConfig.Proxy, "proxy", os.Getenv("PIPER_proxy"), "Proxy URL which should be used for communication with the SAP Cloud Transport Management service backend.")
cmd.Flags().StringSliceVar(&stepConfig.StashContent, "stashContent", []string{`buildResult`}, "If specific stashes should be considered during Jenkins execution, their names need to be passed as a list via this parameter, e.g. stashContent: [\"deployDescriptor\", \"buildResult\"]. By default, the build result is considered.")
cmd.MarkFlagRequired("tmsServiceKey")
cmd.MarkFlagRequired("serviceKey")
cmd.MarkFlagRequired("nodeName")
}
@ -196,18 +199,27 @@ func tmsUploadMetadata() config.StepData {
Spec: config.StepSpec{
Inputs: config.StepInputs{
Secrets: []config.StepSecrets{
{Name: "credentialsId", Description: "Jenkins 'Secret text' credentials ID containing service key for SAP Cloud Transport Management service.", Type: "jenkins"},
{Name: "credentialsId", Description: "Jenkins 'Secret text' credentials ID containing service key for TMS (SAP Cloud Transport Management service) or CALM (SAP Cloud Application Lifecycle Management) service.", Type: "jenkins"},
},
Resources: []config.StepResources{
{Name: "buildResult", Type: "stash"},
},
Parameters: []config.StepParameters{
{
Name: "tmsServiceKey",
Name: "tmsServiceKey",
ResourceRef: []config.ResourceReference{},
Scope: []string{"PARAMETERS", "STEPS", "STAGES"},
Type: "string",
Mandatory: false,
Aliases: []config.Alias{},
Default: os.Getenv("PIPER_tmsServiceKey"),
},
{
Name: "serviceKey",
ResourceRef: []config.ResourceReference{
{
Name: "credentialsId",
Param: "tmsServiceKey",
Param: "serviceKey",
Type: "secret",
},
},
@ -215,7 +227,7 @@ func tmsUploadMetadata() config.StepData {
Type: "string",
Mandatory: true,
Aliases: []config.Alias{},
Default: os.Getenv("PIPER_tmsServiceKey"),
Default: os.Getenv("PIPER_serviceKey"),
},
{
Name: "customDescription",

View File

@ -506,3 +506,50 @@ func TestRunTmsUpload(t *testing.T) {
assert.EqualError(t, err, "failed to upload file to node: Something went wrong on uploading file to node")
})
}
func Test_convertUploadOptions(t *testing.T) {
t.Parallel()
mockServiceKey := `no real serviceKey json necessary for these tests`
t.Run("Use of new serviceKey parameter works", func(t *testing.T) {
t.Parallel()
// init
config := tmsUploadOptions{ServiceKey: mockServiceKey}
wantOptions := tms.Options{ServiceKey: mockServiceKey, CustomDescription: "Created by Piper"}
// test
gotOptions := convertUploadOptions(config)
// assert
assert.Equal(t, wantOptions, gotOptions)
})
t.Run("Use of old tmsServiceKey parameter works as well", func(t *testing.T) {
t.Parallel()
// init
config := tmsUploadOptions{TmsServiceKey: mockServiceKey}
wantOptions := tms.Options{ServiceKey: mockServiceKey, CustomDescription: "Created by Piper"}
// test
gotOptions := convertUploadOptions(config)
// assert
assert.Equal(t, wantOptions, gotOptions)
})
t.Run("Use of both tmsServiceKey and serviceKey parameter favors the new serviceKey parameter", func(t *testing.T) {
t.Parallel()
// init
config := tmsUploadOptions{ServiceKey: mockServiceKey, TmsServiceKey: "some other string"}
wantOptions := tms.Options{ServiceKey: mockServiceKey, CustomDescription: "Created by Piper"}
// test
gotOptions := convertUploadOptions(config)
// assert
assert.Equal(t, wantOptions, gotOptions)
})
}

View File

@ -28,8 +28,13 @@ type uaa struct {
}
type serviceKey struct {
Uaa uaa `json:"uaa"`
Uri string `json:"uri"`
Uaa uaa `json:"uaa"`
Uri string `json:"uri"`
CALMEndpoints cALMEndpoints `json:"endpoints"`
}
type cALMEndpoints *struct {
API string `json:"Api"`
}
type CommunicationInstance struct {
@ -105,15 +110,15 @@ type CommunicationInterface interface {
}
type Options struct {
TmsServiceKey string `json:"tmsServiceKey,omitempty"`
CustomDescription string `json:"customDescription,omitempty"`
NamedUser string `json:"namedUser,omitempty"`
NodeName string `json:"nodeName,omitempty"`
MtaPath string `json:"mtaPath,omitempty"`
MtaVersion string `json:"mtaVersion,omitempty"`
NodeExtDescriptorMapping map[string]interface{} `json:"nodeExtDescriptorMapping,omitempty"`
Proxy string `json:"proxy,omitempty"`
StashContent []string `json:"stashContent,omitempty"`
ServiceKey string
CustomDescription string
NamedUser string
NodeName string
MtaPath string
MtaVersion string
NodeExtDescriptorMapping map[string]interface{}
Proxy string
StashContent []string
Verbose bool
}
@ -123,6 +128,7 @@ type tmsUtilsBundle struct {
}
const DEFAULT_TR_DESCRIPTION = "Created by Piper"
const CALM_REROUTING_ENDPOINT_TO_CTMS = "/imp-cdm-transport-management-api/v1"
func NewTmsUtils() TmsUtils {
utils := tmsUtilsBundle{
@ -140,6 +146,14 @@ func unmarshalServiceKey(serviceKeyJson string) (serviceKey serviceKey, err erro
if err != nil {
return
}
if len(serviceKey.Uri) == 0 {
if serviceKey.CALMEndpoints != nil && len(serviceKey.CALMEndpoints.API) > 0 {
serviceKey.Uri = serviceKey.CALMEndpoints.API + CALM_REROUTING_ENDPOINT_TO_CTMS
} else {
err = fmt.Errorf("neither uri nor endpoints.Api is set in service key json string")
return
}
}
return
}
@ -237,9 +251,9 @@ func SetupCommunication(config Options) (communicationInstance CommunicationInte
}
}
serviceKey, err := unmarshalServiceKey(config.TmsServiceKey)
serviceKey, err := unmarshalServiceKey(config.ServiceKey)
if err != nil {
log.Entry().WithError(err).Fatal("Failed to unmarshal TMS service key")
log.Entry().WithError(err).Fatal("Failed to unmarshal service key")
}
log.RegisterSecret(serviceKey.Uaa.ClientSecret)

47
pkg/tms/tmsUtils_test.go Normal file
View File

@ -0,0 +1,47 @@
package tms
import (
"github.com/stretchr/testify/assert"
"testing"
)
func Test_unmarshalServiceKey(t *testing.T) {
tests := []struct {
name string
serviceKeyJson string
wantTmsUrl string
errMessage string
}{
{
name: "standard cTMS service key uri works",
serviceKeyJson: `{"uri": "https://my.tms.endpoint.sap.com"}`,
wantTmsUrl: "https://my.tms.endpoint.sap.com",
},
{
name: "standard cALM service key uri has expected postfix",
serviceKeyJson: `{"endpoints": {"Api": "https://my.alm.endpoint.sap.com"}}`,
wantTmsUrl: "https://my.alm.endpoint.sap.com/imp-cdm-transport-management-api/v1",
},
{
name: "no uri or endpoints in service key leads to error",
serviceKeyJson: `{"missing key options": "leads to error"}`,
errMessage: "neither uri nor endpoints.Api is set in service key json string",
},
{
name: "faulty json leads to error",
serviceKeyJson: `"this is not correct json"`,
errMessage: "json: cannot unmarshal string into Go value of type tms.serviceKey",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotServiceKey, err := unmarshalServiceKey(tt.serviceKeyJson)
if tt.errMessage == "" {
assert.NoError(t, err, "No error was expected")
assert.Equal(t, tt.wantTmsUrl, gotServiceKey.Uri, "Expected tms url does not match the uri in the service key")
} else {
assert.EqualError(t, err, tt.errMessage, "Error message not as expected")
}
})
}
}

View File

@ -9,12 +9,12 @@ metadata:
!!! note "Prerequisites"
* You have subscribed to and set up TMS, as described in [Initial Setup](https://help.sap.com/viewer/7f7160ec0d8546c6b3eab72fb5ad6fd8/Cloud/en-US/66fd7283c62f48adb23c56fb48c84a60.html), which includes the configuration of your transport landscape.
* A corresponding service key has been created, as described in [Set Up the Environment to Transport Content Archives directly in an Application](https://help.sap.com/viewer/7f7160ec0d8546c6b3eab72fb5ad6fd8/Cloud/en-US/8d9490792ed14f1bbf8a6ac08a6bca64.html). This service key (JSON) must be stored as a secret text within the Jenkins secure store or provided as value of tmsServiceKey parameter.
* A corresponding service key has been created, as described in [Set Up the Environment to Transport Content Archives directly in an Application](https://help.sap.com/viewer/7f7160ec0d8546c6b3eab72fb5ad6fd8/Cloud/en-US/8d9490792ed14f1bbf8a6ac08a6bca64.html). This service key (JSON) must be stored as a secret text within the Jenkins secure store or provided as value of serviceKey parameter.
spec:
inputs:
secrets:
- name: credentialsId
description: Jenkins 'Secret text' credentials ID containing service key for SAP Cloud Transport Management service.
description: Jenkins 'Secret text' credentials ID containing service key for TMS (SAP Cloud Transport Management service) or CALM (SAP Cloud Application Lifecycle Management) service.
type: jenkins
resources:
- name: buildResult
@ -22,7 +22,25 @@ spec:
params:
- name: tmsServiceKey
type: string
description: Service key JSON string to access the SAP Cloud Transport Management service instance APIs. If not specified and if pipeline is running on Jenkins, service key, stored under ID provided with credentialsId parameter, is used.
description: >
DEPRECATION WARNING: This parameter has been deprecated, please use the serviceKey parameter instead,
which supports both service key for TMS (SAP Cloud Transport Management service),
as well as service key for CALM (SAP Cloud Application Lifecycle Management) service.
Service key JSON string to access the SAP Cloud Transport Management service instance APIs.
scope:
- PARAMETERS
- STEPS
- STAGES
mandatory: false
secret: true
- name: serviceKey
type: string
description: >
Service key JSON string to access TMS (SAP Cloud Transport Management service) instance APIs.
This can be a service key for TMS,
or a service key for CALM (SAP Cloud Application Lifecycle Management) service.
If not specified and if pipeline is running on Jenkins, service key, stored under ID provided with credentialsId parameter, is used.
scope:
- PARAMETERS
- STEPS
@ -32,7 +50,7 @@ spec:
resourceRef:
- name: credentialsId
type: secret
param: tmsServiceKey
param: serviceKey
- name: customDescription
type: string
description: Can be used as the description of a transport request. Will overwrite the default, which is corresponding Git commit ID.

View File

@ -9,12 +9,12 @@ metadata:
!!! note "Prerequisites"
* You have subscribed to and set up TMS, as described in [Initial Setup](https://help.sap.com/viewer/7f7160ec0d8546c6b3eab72fb5ad6fd8/Cloud/en-US/66fd7283c62f48adb23c56fb48c84a60.html), which includes the configuration of a node to be used for uploading an MTA file.
* A corresponding service key has been created, as described in [Set Up the Environment to Transport Content Archives directly in an Application](https://help.sap.com/viewer/7f7160ec0d8546c6b3eab72fb5ad6fd8/Cloud/en-US/8d9490792ed14f1bbf8a6ac08a6bca64.html). This service key (JSON) must be stored as a secret text within the Jenkins secure store or provided as value of tmsServiceKey parameter.
* A corresponding service key has been created, as described in [Set Up the Environment to Transport Content Archives directly in an Application](https://help.sap.com/viewer/7f7160ec0d8546c6b3eab72fb5ad6fd8/Cloud/en-US/8d9490792ed14f1bbf8a6ac08a6bca64.html). This service key (JSON) must be stored as a secret text within the Jenkins secure store or provided as value of serviceKey parameter.
spec:
inputs:
secrets:
- name: credentialsId
description: Jenkins 'Secret text' credentials ID containing service key for SAP Cloud Transport Management service.
description: Jenkins 'Secret text' credentials ID containing service key for TMS (SAP Cloud Transport Management service) or CALM (SAP Cloud Application Lifecycle Management) service.
type: jenkins
resources:
- name: buildResult
@ -22,7 +22,25 @@ spec:
params:
- name: tmsServiceKey
type: string
description: Service key JSON string to access the SAP Cloud Transport Management service instance APIs. If not specified and if pipeline is running on Jenkins, service key, stored under ID provided with credentialsId parameter, is used.
description: >
DEPRECATION WARNING: This parameter has been deprecated, please use the serviceKey parameter instead,
which supports both service key for TMS (SAP Cloud Transport Management service),
as well as service key for CALM (SAP Cloud Application Lifecycle Management) service.
Service key JSON string to access the SAP Cloud Transport Management service instance APIs.
scope:
- PARAMETERS
- STEPS
- STAGES
mandatory: false
secret: true
- name: serviceKey
type: string
description: >
Service key JSON string to access TMS (SAP Cloud Transport Management service) instance APIs.
This can be a service key for TMS,
or a service key for CALM (SAP Cloud Application Lifecycle Management) service.
If not specified and if pipeline is running on Jenkins, service key, stored under ID provided with credentialsId parameter, is used.
scope:
- PARAMETERS
- STEPS
@ -32,7 +50,7 @@ spec:
resourceRef:
- name: credentialsId
type: secret
param: tmsServiceKey
param: serviceKey
- name: customDescription
type: string
description: Can be used as the description of a transport request. Will overwrite the default, which is corresponding Git commit ID.

View File

@ -115,7 +115,7 @@ public class TmsUploadTest extends BasePiperTest {
// contains assertion does not work apparently when comparing a list of lists against an expected list
boolean found = false
credInfo.each { entry ->
if (entry == [type: 'token', id: 'credentialsId', env: ['PIPER_tmsServiceKey']]) {
if (entry == [type: 'token', id: 'credentialsId', env: ['PIPER_serviceKey']]) {
found = true
}
}

View File

@ -6,7 +6,7 @@ import com.sap.piper.JenkinsUtils
void call(Map parameters = [:]) {
List credentials = [
[type: 'token', id: 'credentialsId', env: ['PIPER_tmsServiceKey']]
[type: 'token', id: 'credentialsId', env: ['PIPER_serviceKey']]
]
piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials, false, false, true)

View File

@ -96,7 +96,7 @@ void call(Map parameters = [:]) {
if (config.useGoStep != false) {
List credentials = [
[type: 'token', id: 'credentialsId', env: ['PIPER_tmsServiceKey']]
[type: 'token', id: 'credentialsId', env: ['PIPER_serviceKey']]
]
if (namedUser) {