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 
			
		
		
		
	CPI - Introduce service key (#2901)
* Switch to service key for CPI GetMplStatus
Introduces read method for service key files, mock utils and tests.
* Use secret text instead of file
* Change serviceKey definition
* Update cpiUpload to use Service Key
retrieved the host and uaa information from service key
* Update cpiDeploy to use service key
retrieved the host and uaa information from service key
* Update cpiServiceEndpoint to use Service Key
retrieved the host and uaa information from service key
* Update cpiDownload to use Service Key
retrieved the host and uaa information from service key
* Update cpiUpdateConfig to use Service Key
retrieved the host and uaa information from service key
* Refactor serviceKey var name
* Fixed references to service key to follow the real format
they should be accessed through oauth instead of uaa because of the format of the json
* Rename ServiceKey to APIServiceKey
To support having a different service key(and for readability), we need to change the name to API.
* Add STAGES and STEPS yaml
add in to each yaml file of cpi integration
* Revert "Add STAGES and STEPS yaml"
This reverts commit aa2665d158.
* Change comments/formatting commonUtils
Make comments more understandable and follow code climate suggestions
* Change documentation files for steps
remove OAuth and host and change credentials to be servicekey
Co-authored-by: Oliver Feldmann <oliver.feldmann@sap.com>
Co-authored-by: Thorsten Duda <thorsten.duda@sap.com>
			
			
This commit is contained in:
		| @@ -68,8 +68,13 @@ func runIntegrationArtifactDeploy(config *integrationArtifactDeployOptions, tele | ||||
| 	clientOptions := piperhttp.ClientOptions{} | ||||
| 	header := make(http.Header) | ||||
| 	header.Add("Accept", "application/json") | ||||
| 	deployURL := fmt.Sprintf("%s/api/v1/DeployIntegrationDesigntimeArtifact?Id='%s'&Version='%s'", config.Host, config.IntegrationFlowID, config.IntegrationFlowVersion) | ||||
| 	tokenParameters := cpi.TokenParameters{TokenURL: config.OAuthTokenProviderURL, Username: config.Username, Password: config.Password, Client: httpClient} | ||||
| 	serviceKey, err := cpi.ReadCpiServiceKey(config.APIServiceKey) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	deployURL := fmt.Sprintf("%s/api/v1/DeployIntegrationDesigntimeArtifact?Id='%s'&Version='%s'", serviceKey.OAuth.Host, config.IntegrationFlowID, config.IntegrationFlowVersion) | ||||
|  | ||||
| 	tokenParameters := cpi.TokenParameters{TokenURL: serviceKey.OAuth.OAuthTokenProviderURL, Username: serviceKey.OAuth.ClientID, Password: serviceKey.OAuth.ClientSecret, Client: httpClient} | ||||
| 	token, err := cpi.CommonUtils.GetBearerToken(tokenParameters) | ||||
| 	if err != nil { | ||||
| 		return errors.Wrap(err, "failed to fetch Bearer Token") | ||||
| @@ -94,7 +99,7 @@ func runIntegrationArtifactDeploy(config *integrationArtifactDeployOptions, tele | ||||
| 		log.Entry(). | ||||
| 			WithField("IntegrationFlowID", config.IntegrationFlowID). | ||||
| 			Info("successfully deployed into CPI runtime") | ||||
| 		deploymentError := pollIFlowDeploymentStatus(retryCount, config, httpClient) | ||||
| 		deploymentError := pollIFlowDeploymentStatus(retryCount, config, httpClient, serviceKey.OAuth.Host) | ||||
| 		return deploymentError | ||||
| 	} | ||||
| 	responseBody, readErr := ioutil.ReadAll(deployResp.Body) | ||||
| @@ -107,12 +112,12 @@ func runIntegrationArtifactDeploy(config *integrationArtifactDeployOptions, tele | ||||
| } | ||||
|  | ||||
| //pollIFlowDeploymentStatus - Poll the integration flow deployment status, return status or error details | ||||
| func pollIFlowDeploymentStatus(retryCount int, config *integrationArtifactDeployOptions, httpClient piperhttp.Sender) error { | ||||
| func pollIFlowDeploymentStatus(retryCount int, config *integrationArtifactDeployOptions, httpClient piperhttp.Sender, apiHost string) error { | ||||
|  | ||||
| 	if retryCount <= 0 { | ||||
| 		return errors.New("failed to start integration artifact after retrying several times") | ||||
| 	} | ||||
| 	deployStatus, err := getIntegrationArtifactDeployStatus(config, httpClient) | ||||
| 	deployStatus, err := getIntegrationArtifactDeployStatus(config, httpClient, apiHost) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| @@ -124,7 +129,7 @@ func pollIFlowDeploymentStatus(retryCount int, config *integrationArtifactDeploy | ||||
| 		sleepTime := int(retryCount * 3) | ||||
| 		time.Sleep(time.Duration(sleepTime) * time.Second) | ||||
| 		retryCount-- | ||||
| 		return pollIFlowDeploymentStatus(retryCount, config, httpClient) | ||||
| 		return pollIFlowDeploymentStatus(retryCount, config, httpClient, apiHost) | ||||
| 	} | ||||
|  | ||||
| 	//if artifact started, then just return | ||||
| @@ -134,7 +139,7 @@ func pollIFlowDeploymentStatus(retryCount int, config *integrationArtifactDeploy | ||||
|  | ||||
| 	//if error return immediately with error details | ||||
| 	if deployStatus == "ERROR" { | ||||
| 		resp, err := getIntegrationArtifactDeployError(config, httpClient) | ||||
| 		resp, err := getIntegrationArtifactDeployError(config, httpClient, apiHost) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| @@ -154,12 +159,12 @@ func getHTTPErrorMessage(httpErr error, response *http.Response, httpMethod, sta | ||||
| } | ||||
|  | ||||
| //getIntegrationArtifactDeployStatus - Get integration artifact Deploy Status | ||||
| func getIntegrationArtifactDeployStatus(config *integrationArtifactDeployOptions, httpClient piperhttp.Sender) (string, error) { | ||||
| func getIntegrationArtifactDeployStatus(config *integrationArtifactDeployOptions, httpClient piperhttp.Sender, apiHost string) (string, error) { | ||||
| 	httpMethod := "GET" | ||||
| 	header := make(http.Header) | ||||
| 	header.Add("content-type", "application/json") | ||||
| 	header.Add("Accept", "application/json") | ||||
| 	deployStatusURL := fmt.Sprintf("%s/api/v1/IntegrationRuntimeArtifacts('%s')", config.Host, config.IntegrationFlowID) | ||||
| 	deployStatusURL := fmt.Sprintf("%s/api/v1/IntegrationRuntimeArtifacts('%s')", apiHost, config.IntegrationFlowID) | ||||
| 	deployStatusResp, httpErr := httpClient.SendRequest(httpMethod, deployStatusURL, nil, header, nil) | ||||
|  | ||||
| 	if deployStatusResp != nil && deployStatusResp.Body != nil { | ||||
| @@ -193,11 +198,11 @@ func getIntegrationArtifactDeployStatus(config *integrationArtifactDeployOptions | ||||
| } | ||||
|  | ||||
| //getIntegrationArtifactDeployError - Get integration artifact deploy error details | ||||
| func getIntegrationArtifactDeployError(config *integrationArtifactDeployOptions, httpClient piperhttp.Sender) (string, error) { | ||||
| func getIntegrationArtifactDeployError(config *integrationArtifactDeployOptions, httpClient piperhttp.Sender, apiHost string) (string, error) { | ||||
| 	httpMethod := "GET" | ||||
| 	header := make(http.Header) | ||||
| 	header.Add("content-type", "application/json") | ||||
| 	errorStatusURL := fmt.Sprintf("%s/api/v1/IntegrationRuntimeArtifacts('%s')/ErrorInformation/$value", config.Host, config.IntegrationFlowID) | ||||
| 	errorStatusURL := fmt.Sprintf("%s/api/v1/IntegrationRuntimeArtifacts('%s')/ErrorInformation/$value", apiHost, config.IntegrationFlowID) | ||||
| 	errorStatusResp, httpErr := httpClient.SendRequest(httpMethod, errorStatusURL, nil, header, nil) | ||||
|  | ||||
| 	if errorStatusResp != nil && errorStatusResp.Body != nil { | ||||
|   | ||||
| @@ -15,13 +15,10 @@ import ( | ||||
| ) | ||||
|  | ||||
| type integrationArtifactDeployOptions struct { | ||||
| 	Username               string `json:"username,omitempty"` | ||||
| 	Password               string `json:"password,omitempty"` | ||||
| 	APIServiceKey          string `json:"apiServiceKey,omitempty"` | ||||
| 	IntegrationFlowID      string `json:"integrationFlowId,omitempty"` | ||||
| 	IntegrationFlowVersion string `json:"integrationFlowVersion,omitempty"` | ||||
| 	Platform               string `json:"platform,omitempty"` | ||||
| 	Host                   string `json:"host,omitempty"` | ||||
| 	OAuthTokenProviderURL  string `json:"oAuthTokenProviderUrl,omitempty"` | ||||
| } | ||||
|  | ||||
| // IntegrationArtifactDeployCommand Deploy a CPI integration flow | ||||
| @@ -51,8 +48,7 @@ func IntegrationArtifactDeployCommand() *cobra.Command { | ||||
| 				log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 				return err | ||||
| 			} | ||||
| 			log.RegisterSecret(stepConfig.Username) | ||||
| 			log.RegisterSecret(stepConfig.Password) | ||||
| 			log.RegisterSecret(stepConfig.APIServiceKey) | ||||
|  | ||||
| 			if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 { | ||||
| 				sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID) | ||||
| @@ -99,20 +95,14 @@ func IntegrationArtifactDeployCommand() *cobra.Command { | ||||
| } | ||||
|  | ||||
| func addIntegrationArtifactDeployFlags(cmd *cobra.Command, stepConfig *integrationArtifactDeployOptions) { | ||||
| 	cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User to authenticate to the SAP Cloud Platform Integration Service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password to authenticate to the SAP Cloud Platform Integration Service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.APIServiceKey, "apiServiceKey", os.Getenv("PIPER_apiServiceKey"), "Service key JSON string to access the Cloud Integration API") | ||||
| 	cmd.Flags().StringVar(&stepConfig.IntegrationFlowID, "integrationFlowId", os.Getenv("PIPER_integrationFlowId"), "Specifies the ID of the Integration Flow artifact") | ||||
| 	cmd.Flags().StringVar(&stepConfig.IntegrationFlowVersion, "integrationFlowVersion", os.Getenv("PIPER_integrationFlowVersion"), "Specifies the version of the Integration Flow artifact") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Platform, "platform", os.Getenv("PIPER_platform"), "Specifies the running platform of the SAP Cloud platform integraion service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Host, "host", os.Getenv("PIPER_host"), "Specifies the protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.") | ||||
| 	cmd.Flags().StringVar(&stepConfig.OAuthTokenProviderURL, "oAuthTokenProviderUrl", os.Getenv("PIPER_oAuthTokenProviderUrl"), "Specifies the oAuth Provider protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.") | ||||
|  | ||||
| 	cmd.MarkFlagRequired("username") | ||||
| 	cmd.MarkFlagRequired("password") | ||||
| 	cmd.MarkFlagRequired("apiServiceKey") | ||||
| 	cmd.MarkFlagRequired("integrationFlowId") | ||||
| 	cmd.MarkFlagRequired("integrationFlowVersion") | ||||
| 	cmd.MarkFlagRequired("host") | ||||
| 	cmd.MarkFlagRequired("oAuthTokenProviderUrl") | ||||
| } | ||||
|  | ||||
| // retrieve step metadata | ||||
| @@ -126,38 +116,23 @@ func integrationArtifactDeployMetadata() config.StepData { | ||||
| 		Spec: config.StepSpec{ | ||||
| 			Inputs: config.StepInputs{ | ||||
| 				Secrets: []config.StepSecrets{ | ||||
| 					{Name: "cpiCredentialsId", Description: "Jenkins credentials ID containing username and password for authentication to the SAP Cloud Platform Integration API's", Type: "jenkins"}, | ||||
| 					{Name: "cpiAPIServiceKeyCredentialId", Description: "Jenkins credential ID for secret text containing the service key to the SAP Cloud Integration API", Type: "jenkins"}, | ||||
| 				}, | ||||
| 				Parameters: []config.StepParameters{ | ||||
| 					{ | ||||
| 						Name: "username", | ||||
| 						Name: "apiServiceKey", | ||||
| 						ResourceRef: []config.ResourceReference{ | ||||
| 							{ | ||||
| 								Name:  "cpiCredentialsId", | ||||
| 								Param: "username", | ||||
| 								Name:  "cpiServiceKeyCredentialId", | ||||
| 								Param: "serviceKey", | ||||
| 								Type:  "secret", | ||||
| 							}, | ||||
| 						}, | ||||
| 						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Scope:     []string{"PARAMETERS"}, | ||||
| 						Type:      "string", | ||||
| 						Mandatory: true, | ||||
| 						Aliases:   []config.Alias{}, | ||||
| 						Default:   os.Getenv("PIPER_username"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name: "password", | ||||
| 						ResourceRef: []config.ResourceReference{ | ||||
| 							{ | ||||
| 								Name:  "cpiCredentialsId", | ||||
| 								Param: "password", | ||||
| 								Type:  "secret", | ||||
| 							}, | ||||
| 						}, | ||||
| 						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:      "string", | ||||
| 						Mandatory: true, | ||||
| 						Aliases:   []config.Alias{}, | ||||
| 						Default:   os.Getenv("PIPER_password"), | ||||
| 						Default:   os.Getenv("PIPER_apiServiceKey"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "integrationFlowId", | ||||
| @@ -186,24 +161,6 @@ func integrationArtifactDeployMetadata() config.StepData { | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_platform"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "host", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   true, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_host"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "oAuthTokenProviderUrl", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   true, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_oAuthTokenProviderUrl"), | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
|   | ||||
| @@ -29,12 +29,17 @@ func TestRunIntegrationArtifactDeploy(t *testing.T) { | ||||
| 	t.Parallel() | ||||
|  | ||||
| 	t.Run("Successfull Integration Flow Deploy Test", func(t *testing.T) { | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
|  | ||||
| 		config := integrationArtifactDeployOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			Platform:               "cf", | ||||
| @@ -58,11 +63,17 @@ func TestRunIntegrationArtifactDeploy(t *testing.T) { | ||||
|  | ||||
| 	t.Run("Trigger Failure for Integration Flow Deployment", func(t *testing.T) { | ||||
|  | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
|  | ||||
| 		config := integrationArtifactDeployOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			Platform:               "cf", | ||||
| @@ -86,11 +97,17 @@ func TestRunIntegrationArtifactDeploy(t *testing.T) { | ||||
|  | ||||
| 	t.Run("Failed Integration Flow Deploy Test", func(t *testing.T) { | ||||
|  | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
|  | ||||
| 		config := integrationArtifactDeployOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			Platform:               "cf", | ||||
| @@ -106,11 +123,17 @@ func TestRunIntegrationArtifactDeploy(t *testing.T) { | ||||
| 	t.Run("Successfull GetIntegrationArtifactDeployStatus Test", func(t *testing.T) { | ||||
| 		clientOptions := piperhttp.ClientOptions{} | ||||
| 		clientOptions.Token = fmt.Sprintf("Bearer %s", "Demo") | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
|  | ||||
| 		config := integrationArtifactDeployOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			Platform:               "cf", | ||||
| @@ -118,7 +141,7 @@ func TestRunIntegrationArtifactDeploy(t *testing.T) { | ||||
|  | ||||
| 		httpClient := httpMockCpis{CPIFunction: "GetIntegrationArtifactDeployStatus", Options: clientOptions, ResponseBody: ``, TestType: "PositiveAndDeployIntegrationDesigntimeArtifactResBody"} | ||||
|  | ||||
| 		resp, err := getIntegrationArtifactDeployStatus(&config, &httpClient) | ||||
| 		resp, err := getIntegrationArtifactDeployStatus(&config, &httpClient, "https://demo") | ||||
|  | ||||
| 		assert.Equal(t, "STARTED", resp) | ||||
|  | ||||
| @@ -128,11 +151,17 @@ func TestRunIntegrationArtifactDeploy(t *testing.T) { | ||||
| 	t.Run("Successfull GetIntegrationArtifactDeployError Test", func(t *testing.T) { | ||||
| 		clientOptions := piperhttp.ClientOptions{} | ||||
| 		clientOptions.Token = fmt.Sprintf("Bearer %s", "Demo") | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
|  | ||||
| 		config := integrationArtifactDeployOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			Platform:               "cf", | ||||
| @@ -140,7 +169,7 @@ func TestRunIntegrationArtifactDeploy(t *testing.T) { | ||||
|  | ||||
| 		httpClient := httpMockCpis{CPIFunction: "GetIntegrationArtifactDeployErrorDetails", Options: clientOptions, ResponseBody: ``, TestType: "PositiveAndGetDeployedIntegrationDesigntimeArtifactErrorResBody"} | ||||
|  | ||||
| 		resp, err := getIntegrationArtifactDeployError(&config, &httpClient) | ||||
| 		resp, err := getIntegrationArtifactDeployError(&config, &httpClient, "https://demo") | ||||
|  | ||||
| 		assert.Equal(t, "{\"message\": \"java.lang.IllegalStateException: No credentials for 'smtp' found\"}", resp) | ||||
|  | ||||
|   | ||||
| @@ -66,8 +66,12 @@ func runIntegrationArtifactDownload(config *integrationArtifactDownloadOptions, | ||||
| 	clientOptions := piperhttp.ClientOptions{} | ||||
| 	header := make(http.Header) | ||||
| 	header.Add("Accept", "application/zip") | ||||
| 	downloadArtifactURL := fmt.Sprintf("%s/api/v1/IntegrationDesigntimeArtifacts(Id='%s',Version='%s')/$value", config.Host, config.IntegrationFlowID, config.IntegrationFlowVersion) | ||||
| 	tokenParameters := cpi.TokenParameters{TokenURL: config.OAuthTokenProviderURL, Username: config.Username, Password: config.Password, Client: httpClient} | ||||
| 	serviceKey, err := cpi.ReadCpiServiceKey(config.APIServiceKey) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	downloadArtifactURL := fmt.Sprintf("%s/api/v1/IntegrationDesigntimeArtifacts(Id='%s',Version='%s')/$value", serviceKey.OAuth.Host, config.IntegrationFlowID, config.IntegrationFlowVersion) | ||||
| 	tokenParameters := cpi.TokenParameters{TokenURL: serviceKey.OAuth.OAuthTokenProviderURL, Username: serviceKey.OAuth.ClientID, Password: serviceKey.OAuth.ClientSecret, Client: httpClient} | ||||
| 	token, err := cpi.CommonUtils.GetBearerToken(tokenParameters) | ||||
| 	if err != nil { | ||||
| 		return errors.Wrap(err, "failed to fetch Bearer Token") | ||||
|   | ||||
| @@ -15,12 +15,9 @@ import ( | ||||
| ) | ||||
|  | ||||
| type integrationArtifactDownloadOptions struct { | ||||
| 	Username               string `json:"username,omitempty"` | ||||
| 	Password               string `json:"password,omitempty"` | ||||
| 	APIServiceKey          string `json:"apiServiceKey,omitempty"` | ||||
| 	IntegrationFlowID      string `json:"integrationFlowId,omitempty"` | ||||
| 	IntegrationFlowVersion string `json:"integrationFlowVersion,omitempty"` | ||||
| 	Host                   string `json:"host,omitempty"` | ||||
| 	OAuthTokenProviderURL  string `json:"oAuthTokenProviderUrl,omitempty"` | ||||
| 	DownloadPath           string `json:"downloadPath,omitempty"` | ||||
| } | ||||
|  | ||||
| @@ -51,8 +48,7 @@ func IntegrationArtifactDownloadCommand() *cobra.Command { | ||||
| 				log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 				return err | ||||
| 			} | ||||
| 			log.RegisterSecret(stepConfig.Username) | ||||
| 			log.RegisterSecret(stepConfig.Password) | ||||
| 			log.RegisterSecret(stepConfig.APIServiceKey) | ||||
|  | ||||
| 			if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 { | ||||
| 				sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID) | ||||
| @@ -99,20 +95,14 @@ func IntegrationArtifactDownloadCommand() *cobra.Command { | ||||
| } | ||||
|  | ||||
| func addIntegrationArtifactDownloadFlags(cmd *cobra.Command, stepConfig *integrationArtifactDownloadOptions) { | ||||
| 	cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User to authenticate to the SAP Cloud Platform Integration Service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password to authenticate to the SAP Cloud Platform Integration Service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.APIServiceKey, "apiServiceKey", os.Getenv("PIPER_apiServiceKey"), "Service key JSON string to access the Cloud Integration API") | ||||
| 	cmd.Flags().StringVar(&stepConfig.IntegrationFlowID, "integrationFlowId", os.Getenv("PIPER_integrationFlowId"), "Specifies the ID of the Integration Flow artifact") | ||||
| 	cmd.Flags().StringVar(&stepConfig.IntegrationFlowVersion, "integrationFlowVersion", os.Getenv("PIPER_integrationFlowVersion"), "Specifies the version of the Integration Flow artifact") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Host, "host", os.Getenv("PIPER_host"), "Specifies the protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.") | ||||
| 	cmd.Flags().StringVar(&stepConfig.OAuthTokenProviderURL, "oAuthTokenProviderUrl", os.Getenv("PIPER_oAuthTokenProviderUrl"), "Specifies the oAuth Provider protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.") | ||||
| 	cmd.Flags().StringVar(&stepConfig.DownloadPath, "downloadPath", os.Getenv("PIPER_downloadPath"), "Specifies integration artifact download location.") | ||||
|  | ||||
| 	cmd.MarkFlagRequired("username") | ||||
| 	cmd.MarkFlagRequired("password") | ||||
| 	cmd.MarkFlagRequired("apiServiceKey") | ||||
| 	cmd.MarkFlagRequired("integrationFlowId") | ||||
| 	cmd.MarkFlagRequired("integrationFlowVersion") | ||||
| 	cmd.MarkFlagRequired("host") | ||||
| 	cmd.MarkFlagRequired("oAuthTokenProviderUrl") | ||||
| 	cmd.MarkFlagRequired("downloadPath") | ||||
| } | ||||
|  | ||||
| @@ -127,38 +117,23 @@ func integrationArtifactDownloadMetadata() config.StepData { | ||||
| 		Spec: config.StepSpec{ | ||||
| 			Inputs: config.StepInputs{ | ||||
| 				Secrets: []config.StepSecrets{ | ||||
| 					{Name: "cpiCredentialsId", Description: "Jenkins credentials ID containing username and password for authentication to the SAP Cloud Platform Integration API's", Type: "jenkins"}, | ||||
| 					{Name: "cpiAPIServiceKeyCredentialId", Description: "Jenkins credential ID for secret text containing the service key to the SAP Cloud Integration API", Type: "jenkins"}, | ||||
| 				}, | ||||
| 				Parameters: []config.StepParameters{ | ||||
| 					{ | ||||
| 						Name: "username", | ||||
| 						Name: "apiServiceKey", | ||||
| 						ResourceRef: []config.ResourceReference{ | ||||
| 							{ | ||||
| 								Name:  "cpiCredentialsId", | ||||
| 								Param: "username", | ||||
| 								Name:  "cpiServiceKeyCredentialId", | ||||
| 								Param: "serviceKey", | ||||
| 								Type:  "secret", | ||||
| 							}, | ||||
| 						}, | ||||
| 						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Scope:     []string{"PARAMETERS"}, | ||||
| 						Type:      "string", | ||||
| 						Mandatory: true, | ||||
| 						Aliases:   []config.Alias{}, | ||||
| 						Default:   os.Getenv("PIPER_username"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name: "password", | ||||
| 						ResourceRef: []config.ResourceReference{ | ||||
| 							{ | ||||
| 								Name:  "cpiCredentialsId", | ||||
| 								Param: "password", | ||||
| 								Type:  "secret", | ||||
| 							}, | ||||
| 						}, | ||||
| 						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:      "string", | ||||
| 						Mandatory: true, | ||||
| 						Aliases:   []config.Alias{}, | ||||
| 						Default:   os.Getenv("PIPER_password"), | ||||
| 						Default:   os.Getenv("PIPER_apiServiceKey"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "integrationFlowId", | ||||
| @@ -178,24 +153,6 @@ func integrationArtifactDownloadMetadata() config.StepData { | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_integrationFlowVersion"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "host", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   true, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_host"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "oAuthTokenProviderUrl", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   true, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_oAuthTokenProviderUrl"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "downloadPath", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
|   | ||||
| @@ -30,11 +30,17 @@ func TestRunIntegrationArtifactDownload(t *testing.T) { | ||||
| 		tempDir, tmpErr := ioutil.TempDir("", "") | ||||
| 		defer os.RemoveAll(tempDir) // clean up | ||||
| 		assert.NoError(t, tmpErr, "Error when creating temp dir") | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
|  | ||||
| 		config := integrationArtifactDownloadOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			DownloadPath:           tempDir, | ||||
| @@ -58,11 +64,17 @@ func TestRunIntegrationArtifactDownload(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	t.Run("Failed case of Integration Flow artifact Download", func(t *testing.T) { | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
|  | ||||
| 		config := integrationArtifactDownloadOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			DownloadPath:           "tmp", | ||||
|   | ||||
| @@ -59,14 +59,24 @@ func integrationArtifactGetMplStatus(config integrationArtifactGetMplStatusOptio | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func runIntegrationArtifactGetMplStatus(config *integrationArtifactGetMplStatusOptions, telemetryData *telemetry.CustomData, httpClient piperhttp.Sender, commonPipelineEnvironment *integrationArtifactGetMplStatusCommonPipelineEnvironment) error { | ||||
| func runIntegrationArtifactGetMplStatus( | ||||
| 	config *integrationArtifactGetMplStatusOptions, | ||||
| 	telemetryData *telemetry.CustomData, | ||||
| 	httpClient piperhttp.Sender, | ||||
| 	commonPipelineEnvironment *integrationArtifactGetMplStatusCommonPipelineEnvironment) error { | ||||
|  | ||||
| 	serviceKey, err := cpi.ReadCpiServiceKey(config.APIServiceKey) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	clientOptions := piperhttp.ClientOptions{} | ||||
| 	httpClient.SetOptions(clientOptions) | ||||
| 	header := make(http.Header) | ||||
| 	header.Add("Accept", "application/json") | ||||
| 	mplStatusEncodedURL := fmt.Sprintf("%s/api/v1/MessageProcessingLogs?$filter=IntegrationArtifact/Id"+url.QueryEscape(" eq ")+"'%s'&$orderby="+ | ||||
| 		url.QueryEscape("LogEnd desc")+"&$top=1", config.Host, config.IntegrationFlowID) | ||||
| 	tokenParameters := cpi.TokenParameters{TokenURL: config.OAuthTokenProviderURL, Username: config.Username, Password: config.Password, Client: httpClient} | ||||
| 		url.QueryEscape("LogEnd desc")+"&$top=1", serviceKey.OAuth.Host, config.IntegrationFlowID) | ||||
| 	tokenParameters := cpi.TokenParameters{TokenURL: serviceKey.OAuth.OAuthTokenProviderURL, Username: serviceKey.OAuth.ClientID, Password: serviceKey.OAuth.ClientSecret, Client: httpClient} | ||||
| 	token, err := cpi.CommonUtils.GetBearerToken(tokenParameters) | ||||
| 	if err != nil { | ||||
| 		return errors.Wrap(err, "failed to fetch Bearer Token") | ||||
|   | ||||
| @@ -17,12 +17,9 @@ import ( | ||||
| ) | ||||
|  | ||||
| type integrationArtifactGetMplStatusOptions struct { | ||||
| 	Username              string `json:"username,omitempty"` | ||||
| 	Password              string `json:"password,omitempty"` | ||||
| 	IntegrationFlowID     string `json:"integrationFlowId,omitempty"` | ||||
| 	Platform              string `json:"platform,omitempty"` | ||||
| 	Host                  string `json:"host,omitempty"` | ||||
| 	OAuthTokenProviderURL string `json:"oAuthTokenProviderUrl,omitempty"` | ||||
| 	APIServiceKey     string `json:"apiServiceKey,omitempty"` | ||||
| 	IntegrationFlowID string `json:"integrationFlowId,omitempty"` | ||||
| 	Platform          string `json:"platform,omitempty"` | ||||
| } | ||||
|  | ||||
| type integrationArtifactGetMplStatusCommonPipelineEnvironment struct { | ||||
| @@ -81,8 +78,7 @@ func IntegrationArtifactGetMplStatusCommand() *cobra.Command { | ||||
| 				log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 				return err | ||||
| 			} | ||||
| 			log.RegisterSecret(stepConfig.Username) | ||||
| 			log.RegisterSecret(stepConfig.Password) | ||||
| 			log.RegisterSecret(stepConfig.APIServiceKey) | ||||
|  | ||||
| 			if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 { | ||||
| 				sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID) | ||||
| @@ -130,18 +126,12 @@ func IntegrationArtifactGetMplStatusCommand() *cobra.Command { | ||||
| } | ||||
|  | ||||
| func addIntegrationArtifactGetMplStatusFlags(cmd *cobra.Command, stepConfig *integrationArtifactGetMplStatusOptions) { | ||||
| 	cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User to authenticate to the SAP Cloud Platform Integration Service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password to authenticate to the SAP Cloud Platform Integration Service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.APIServiceKey, "apiServiceKey", os.Getenv("PIPER_apiServiceKey"), "Service key JSON string to access the Cloud Integration API") | ||||
| 	cmd.Flags().StringVar(&stepConfig.IntegrationFlowID, "integrationFlowId", os.Getenv("PIPER_integrationFlowId"), "Specifies the ID of the Integration Flow artifact") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Platform, "platform", os.Getenv("PIPER_platform"), "Specifies the running platform of the SAP Cloud platform integraion service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Host, "host", os.Getenv("PIPER_host"), "Specifies the protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.") | ||||
| 	cmd.Flags().StringVar(&stepConfig.OAuthTokenProviderURL, "oAuthTokenProviderUrl", os.Getenv("PIPER_oAuthTokenProviderUrl"), "Specifies the oAuth Provider protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.") | ||||
|  | ||||
| 	cmd.MarkFlagRequired("username") | ||||
| 	cmd.MarkFlagRequired("password") | ||||
| 	cmd.MarkFlagRequired("apiServiceKey") | ||||
| 	cmd.MarkFlagRequired("integrationFlowId") | ||||
| 	cmd.MarkFlagRequired("host") | ||||
| 	cmd.MarkFlagRequired("oAuthTokenProviderUrl") | ||||
| } | ||||
|  | ||||
| // retrieve step metadata | ||||
| @@ -155,38 +145,23 @@ func integrationArtifactGetMplStatusMetadata() config.StepData { | ||||
| 		Spec: config.StepSpec{ | ||||
| 			Inputs: config.StepInputs{ | ||||
| 				Secrets: []config.StepSecrets{ | ||||
| 					{Name: "cpiCredentialsId", Description: "Jenkins credentials ID containing username and password for authentication to the SAP Cloud Platform Integration API's", Type: "jenkins"}, | ||||
| 					{Name: "cpiAPIServiceKeyCredentialId", Description: "Jenkins credential ID for secret text containing the service key to the SAP Cloud Integration API", Type: "jenkins"}, | ||||
| 				}, | ||||
| 				Parameters: []config.StepParameters{ | ||||
| 					{ | ||||
| 						Name: "username", | ||||
| 						Name: "apiServiceKey", | ||||
| 						ResourceRef: []config.ResourceReference{ | ||||
| 							{ | ||||
| 								Name:  "cpiCredentialsId", | ||||
| 								Param: "username", | ||||
| 								Name:  "cpiServiceKeyCredentialId", | ||||
| 								Param: "serviceKey", | ||||
| 								Type:  "secret", | ||||
| 							}, | ||||
| 						}, | ||||
| 						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Scope:     []string{"PARAMETERS"}, | ||||
| 						Type:      "string", | ||||
| 						Mandatory: true, | ||||
| 						Aliases:   []config.Alias{}, | ||||
| 						Default:   os.Getenv("PIPER_username"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name: "password", | ||||
| 						ResourceRef: []config.ResourceReference{ | ||||
| 							{ | ||||
| 								Name:  "cpiCredentialsId", | ||||
| 								Param: "password", | ||||
| 								Type:  "secret", | ||||
| 							}, | ||||
| 						}, | ||||
| 						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:      "string", | ||||
| 						Mandatory: true, | ||||
| 						Aliases:   []config.Alias{}, | ||||
| 						Default:   os.Getenv("PIPER_password"), | ||||
| 						Default:   os.Getenv("PIPER_apiServiceKey"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "integrationFlowId", | ||||
| @@ -206,24 +181,6 @@ func integrationArtifactGetMplStatusMetadata() config.StepData { | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_platform"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "host", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   true, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_host"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "oAuthTokenProviderUrl", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   true, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_oAuthTokenProviderUrl"), | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			Outputs: config.StepOutputs{ | ||||
|   | ||||
| @@ -24,21 +24,26 @@ func TestRunIntegrationArtifactGetMplStatus(t *testing.T) { | ||||
| 	t.Parallel() | ||||
|  | ||||
| 	t.Run("Successfully Test of Get Integration Flow MPL Status", func(t *testing.T) { | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
| 		config := integrationArtifactGetMplStatusOptions{ | ||||
| 			Host:                  "https://demo", | ||||
| 			OAuthTokenProviderURL: "https://demo/oauth/token", | ||||
| 			Username:              "demouser", | ||||
| 			Password:              "******", | ||||
| 			IntegrationFlowID:     "flow1", | ||||
| 			Platform:              "cf", | ||||
| 			APIServiceKey:     apiServiceKey, | ||||
| 			IntegrationFlowID: "flow1", | ||||
| 			Platform:          "cf", | ||||
| 		} | ||||
|  | ||||
| 		httpClient := httpMockCpis{CPIFunction: "IntegrationArtifactGetMplStatus", ResponseBody: ``, TestType: "Positive"} | ||||
| 		seOut := integrationArtifactGetMplStatusCommonPipelineEnvironment{} | ||||
| 		err := runIntegrationArtifactGetMplStatus(&config, nil, &httpClient, &seOut) | ||||
| 		assert.EqualValues(t, seOut.custom.iFlowMplStatus, "COMPLETED") | ||||
|  | ||||
| 		if assert.NoError(t, err) { | ||||
| 			assert.EqualValues(t, seOut.custom.iFlowMplStatus, "COMPLETED") | ||||
|  | ||||
| 			t.Run("check url", func(t *testing.T) { | ||||
| 				assert.Equal(t, "https://demo/api/v1/MessageProcessingLogs?$filter=IntegrationArtifact/Id+eq+'flow1'&$orderby=LogEnd+desc&$top=1", httpClient.URL) | ||||
| @@ -52,13 +57,18 @@ func TestRunIntegrationArtifactGetMplStatus(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	t.Run("Failed Test of Get Integration Flow MPL Status", func(t *testing.T) { | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
| 		config := integrationArtifactGetMplStatusOptions{ | ||||
| 			Host:                  "https://demo", | ||||
| 			OAuthTokenProviderURL: "https://demo/oauth/token", | ||||
| 			Username:              "demouser", | ||||
| 			Password:              "******", | ||||
| 			IntegrationFlowID:     "flow1", | ||||
| 			Platform:              "cf", | ||||
| 			APIServiceKey:     apiServiceKey, | ||||
| 			IntegrationFlowID: "flow1", | ||||
| 			Platform:          "cf", | ||||
| 		} | ||||
|  | ||||
| 		httpClient := httpMockCpis{CPIFunction: "IntegrationArtifactGetMplStatus", ResponseBody: ``, TestType: "Negative"} | ||||
|   | ||||
| @@ -64,9 +64,12 @@ func runIntegrationArtifactGetServiceEndpoint(config *integrationArtifactGetServ | ||||
| 	clientOptions := piperhttp.ClientOptions{} | ||||
| 	header := make(http.Header) | ||||
| 	header.Add("Accept", "application/json") | ||||
|  | ||||
| 	servieEndpointURL := fmt.Sprintf("%s/api/v1/ServiceEndpoints?$expand=EntryPoints", config.Host) | ||||
| 	tokenParameters := cpi.TokenParameters{TokenURL: config.OAuthTokenProviderURL, Username: config.Username, Password: config.Password, Client: httpClient} | ||||
| 	serviceKey, err := cpi.ReadCpiServiceKey(config.APIServiceKey) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	servieEndpointURL := fmt.Sprintf("%s/api/v1/ServiceEndpoints?$expand=EntryPoints", serviceKey.OAuth.Host) | ||||
| 	tokenParameters := cpi.TokenParameters{TokenURL: serviceKey.OAuth.OAuthTokenProviderURL, Username: serviceKey.OAuth.ClientID, Password: serviceKey.OAuth.ClientSecret, Client: httpClient} | ||||
| 	token, err := cpi.CommonUtils.GetBearerToken(tokenParameters) | ||||
| 	if err != nil { | ||||
| 		return errors.Wrap(err, "failed to fetch Bearer Token") | ||||
|   | ||||
| @@ -17,12 +17,9 @@ import ( | ||||
| ) | ||||
|  | ||||
| type integrationArtifactGetServiceEndpointOptions struct { | ||||
| 	Username              string `json:"username,omitempty"` | ||||
| 	Password              string `json:"password,omitempty"` | ||||
| 	IntegrationFlowID     string `json:"integrationFlowId,omitempty"` | ||||
| 	Platform              string `json:"platform,omitempty"` | ||||
| 	Host                  string `json:"host,omitempty"` | ||||
| 	OAuthTokenProviderURL string `json:"oAuthTokenProviderUrl,omitempty"` | ||||
| 	APIServiceKey     string `json:"apiServiceKey,omitempty"` | ||||
| 	IntegrationFlowID string `json:"integrationFlowId,omitempty"` | ||||
| 	Platform          string `json:"platform,omitempty"` | ||||
| } | ||||
|  | ||||
| type integrationArtifactGetServiceEndpointCommonPipelineEnvironment struct { | ||||
| @@ -81,8 +78,7 @@ func IntegrationArtifactGetServiceEndpointCommand() *cobra.Command { | ||||
| 				log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 				return err | ||||
| 			} | ||||
| 			log.RegisterSecret(stepConfig.Username) | ||||
| 			log.RegisterSecret(stepConfig.Password) | ||||
| 			log.RegisterSecret(stepConfig.APIServiceKey) | ||||
|  | ||||
| 			if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 { | ||||
| 				sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID) | ||||
| @@ -130,18 +126,12 @@ func IntegrationArtifactGetServiceEndpointCommand() *cobra.Command { | ||||
| } | ||||
|  | ||||
| func addIntegrationArtifactGetServiceEndpointFlags(cmd *cobra.Command, stepConfig *integrationArtifactGetServiceEndpointOptions) { | ||||
| 	cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User to authenticate to the SAP Cloud Platform Integration Service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password to authenticate to the SAP Cloud Platform Integration Service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.APIServiceKey, "apiServiceKey", os.Getenv("PIPER_apiServiceKey"), "Service key JSON string to access the Cloud Integration API") | ||||
| 	cmd.Flags().StringVar(&stepConfig.IntegrationFlowID, "integrationFlowId", os.Getenv("PIPER_integrationFlowId"), "Specifies the ID of the Integration Flow artifact") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Platform, "platform", os.Getenv("PIPER_platform"), "Specifies the running platform of the SAP Cloud platform integraion service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Host, "host", os.Getenv("PIPER_host"), "Specifies the protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.") | ||||
| 	cmd.Flags().StringVar(&stepConfig.OAuthTokenProviderURL, "oAuthTokenProviderUrl", os.Getenv("PIPER_oAuthTokenProviderUrl"), "Specifies the oAuth Provider protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.") | ||||
|  | ||||
| 	cmd.MarkFlagRequired("username") | ||||
| 	cmd.MarkFlagRequired("password") | ||||
| 	cmd.MarkFlagRequired("apiServiceKey") | ||||
| 	cmd.MarkFlagRequired("integrationFlowId") | ||||
| 	cmd.MarkFlagRequired("host") | ||||
| 	cmd.MarkFlagRequired("oAuthTokenProviderUrl") | ||||
| } | ||||
|  | ||||
| // retrieve step metadata | ||||
| @@ -155,38 +145,23 @@ func integrationArtifactGetServiceEndpointMetadata() config.StepData { | ||||
| 		Spec: config.StepSpec{ | ||||
| 			Inputs: config.StepInputs{ | ||||
| 				Secrets: []config.StepSecrets{ | ||||
| 					{Name: "cpiCredentialsId", Description: "Jenkins credentials ID containing username and password for authentication to the SAP Cloud Platform Integration API's", Type: "jenkins"}, | ||||
| 					{Name: "cpiAPIServiceKeyCredentialId", Description: "Jenkins credential ID for secret text containing the service key to the SAP Cloud Integration API", Type: "jenkins"}, | ||||
| 				}, | ||||
| 				Parameters: []config.StepParameters{ | ||||
| 					{ | ||||
| 						Name: "username", | ||||
| 						Name: "apiServiceKey", | ||||
| 						ResourceRef: []config.ResourceReference{ | ||||
| 							{ | ||||
| 								Name:  "cpiCredentialsId", | ||||
| 								Param: "username", | ||||
| 								Name:  "cpiServiceKeyCredentialId", | ||||
| 								Param: "serviceKey", | ||||
| 								Type:  "secret", | ||||
| 							}, | ||||
| 						}, | ||||
| 						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Scope:     []string{"PARAMETERS"}, | ||||
| 						Type:      "string", | ||||
| 						Mandatory: true, | ||||
| 						Aliases:   []config.Alias{}, | ||||
| 						Default:   os.Getenv("PIPER_username"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name: "password", | ||||
| 						ResourceRef: []config.ResourceReference{ | ||||
| 							{ | ||||
| 								Name:  "cpiCredentialsId", | ||||
| 								Param: "password", | ||||
| 								Type:  "secret", | ||||
| 							}, | ||||
| 						}, | ||||
| 						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:      "string", | ||||
| 						Mandatory: true, | ||||
| 						Aliases:   []config.Alias{}, | ||||
| 						Default:   os.Getenv("PIPER_password"), | ||||
| 						Default:   os.Getenv("PIPER_apiServiceKey"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "integrationFlowId", | ||||
| @@ -206,24 +181,6 @@ func integrationArtifactGetServiceEndpointMetadata() config.StepData { | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_platform"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "host", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   true, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_host"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "oAuthTokenProviderUrl", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   true, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_oAuthTokenProviderUrl"), | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			Outputs: config.StepOutputs{ | ||||
|   | ||||
| @@ -24,13 +24,18 @@ func TestRunIntegrationArtifactGetServiceEndpoint(t *testing.T) { | ||||
| 	t.Parallel() | ||||
|  | ||||
| 	t.Run("Successfully Test of Get Integration Flow Service Endpoint", func(t *testing.T) { | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
| 		config := integrationArtifactGetServiceEndpointOptions{ | ||||
| 			Host:                  "https://demo", | ||||
| 			OAuthTokenProviderURL: "https://demo/oauth/token", | ||||
| 			Username:              "demouser", | ||||
| 			Password:              "******", | ||||
| 			IntegrationFlowID:     "CPI_IFlow_Call_using_Cert", | ||||
| 			Platform:              "cf", | ||||
| 			APIServiceKey:     apiServiceKey, | ||||
| 			IntegrationFlowID: "CPI_IFlow_Call_using_Cert", | ||||
| 			Platform:          "cf", | ||||
| 		} | ||||
|  | ||||
| 		httpClient := httpMockCpis{CPIFunction: "IntegrationArtifactGetServiceEndpoint", ResponseBody: ``, TestType: "PositiveAndGetetIntegrationArtifactGetServiceResBody"} | ||||
| @@ -52,13 +57,18 @@ func TestRunIntegrationArtifactGetServiceEndpoint(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	t.Run("Failed Test of Get Integration Flow MPL Status", func(t *testing.T) { | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
| 		config := integrationArtifactGetServiceEndpointOptions{ | ||||
| 			Host:                  "https://demo", | ||||
| 			OAuthTokenProviderURL: "https://demo/oauth/token", | ||||
| 			Username:              "demouser", | ||||
| 			Password:              "******", | ||||
| 			IntegrationFlowID:     "CPI_IFlow_Call_using_Cert", | ||||
| 			Platform:              "cf", | ||||
| 			APIServiceKey:     apiServiceKey, | ||||
| 			IntegrationFlowID: "CPI_IFlow_Call_using_Cert", | ||||
| 			Platform:          "cf", | ||||
| 		} | ||||
|  | ||||
| 		httpClient := httpMockCpis{CPIFunction: "IntegrationArtifactGetServiceEndpoint", ResponseBody: ``, TestType: "Negative"} | ||||
|   | ||||
| @@ -63,9 +63,12 @@ func integrationArtifactUpdateConfiguration(config integrationArtifactUpdateConf | ||||
|  | ||||
| func runIntegrationArtifactUpdateConfiguration(config *integrationArtifactUpdateConfigurationOptions, telemetryData *telemetry.CustomData, httpClient piperhttp.Sender) error { | ||||
| 	clientOptions := piperhttp.ClientOptions{} | ||||
|  | ||||
| 	configUpdateURL := fmt.Sprintf("%s/api/v1/IntegrationDesigntimeArtifacts(Id='%s',Version='%s')/$links/Configurations('%s')", config.Host, config.IntegrationFlowID, config.IntegrationFlowVersion, config.ParameterKey) | ||||
| 	tokenParameters := cpi.TokenParameters{TokenURL: config.OAuthTokenProviderURL, Username: config.Username, Password: config.Password, Client: httpClient} | ||||
| 	serviceKey, err := cpi.ReadCpiServiceKey(config.APIServiceKey) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	configUpdateURL := fmt.Sprintf("%s/api/v1/IntegrationDesigntimeArtifacts(Id='%s',Version='%s')/$links/Configurations('%s')", serviceKey.OAuth.Host, config.IntegrationFlowID, config.IntegrationFlowVersion, config.ParameterKey) | ||||
| 	tokenParameters := cpi.TokenParameters{TokenURL: serviceKey.OAuth.OAuthTokenProviderURL, Username: serviceKey.OAuth.ClientID, Password: serviceKey.OAuth.ClientSecret, Client: httpClient} | ||||
| 	token, err := cpi.CommonUtils.GetBearerToken(tokenParameters) | ||||
| 	if err != nil { | ||||
| 		return errors.Wrap(err, "failed to fetch Bearer Token") | ||||
|   | ||||
| @@ -15,13 +15,10 @@ import ( | ||||
| ) | ||||
|  | ||||
| type integrationArtifactUpdateConfigurationOptions struct { | ||||
| 	Username               string `json:"username,omitempty"` | ||||
| 	Password               string `json:"password,omitempty"` | ||||
| 	APIServiceKey          string `json:"apiServiceKey,omitempty"` | ||||
| 	IntegrationFlowID      string `json:"integrationFlowId,omitempty"` | ||||
| 	IntegrationFlowVersion string `json:"integrationFlowVersion,omitempty"` | ||||
| 	Platform               string `json:"platform,omitempty"` | ||||
| 	Host                   string `json:"host,omitempty"` | ||||
| 	OAuthTokenProviderURL  string `json:"oAuthTokenProviderUrl,omitempty"` | ||||
| 	ParameterKey           string `json:"parameterKey,omitempty"` | ||||
| 	ParameterValue         string `json:"parameterValue,omitempty"` | ||||
| } | ||||
| @@ -53,8 +50,7 @@ func IntegrationArtifactUpdateConfigurationCommand() *cobra.Command { | ||||
| 				log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 				return err | ||||
| 			} | ||||
| 			log.RegisterSecret(stepConfig.Username) | ||||
| 			log.RegisterSecret(stepConfig.Password) | ||||
| 			log.RegisterSecret(stepConfig.APIServiceKey) | ||||
|  | ||||
| 			if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 { | ||||
| 				sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID) | ||||
| @@ -101,22 +97,16 @@ func IntegrationArtifactUpdateConfigurationCommand() *cobra.Command { | ||||
| } | ||||
|  | ||||
| func addIntegrationArtifactUpdateConfigurationFlags(cmd *cobra.Command, stepConfig *integrationArtifactUpdateConfigurationOptions) { | ||||
| 	cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User to authenticate to the SAP Cloud Platform Integration Service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password to authenticate to the SAP Cloud Platform Integration Service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.APIServiceKey, "apiServiceKey", os.Getenv("PIPER_apiServiceKey"), "Service key JSON string to access the Cloud Integration API") | ||||
| 	cmd.Flags().StringVar(&stepConfig.IntegrationFlowID, "integrationFlowId", os.Getenv("PIPER_integrationFlowId"), "Specifies the ID of the Integration Flow artifact") | ||||
| 	cmd.Flags().StringVar(&stepConfig.IntegrationFlowVersion, "integrationFlowVersion", os.Getenv("PIPER_integrationFlowVersion"), "Specifies the version of the Integration Flow artifact") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Platform, "platform", os.Getenv("PIPER_platform"), "Specifies the running platform of the SAP Cloud platform integraion service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Host, "host", os.Getenv("PIPER_host"), "Specifies the protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.") | ||||
| 	cmd.Flags().StringVar(&stepConfig.OAuthTokenProviderURL, "oAuthTokenProviderUrl", os.Getenv("PIPER_oAuthTokenProviderUrl"), "Specifies the oAuth Provider protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.") | ||||
| 	cmd.Flags().StringVar(&stepConfig.ParameterKey, "parameterKey", os.Getenv("PIPER_parameterKey"), "Specifies the externalized parameter name.") | ||||
| 	cmd.Flags().StringVar(&stepConfig.ParameterValue, "parameterValue", os.Getenv("PIPER_parameterValue"), "Specifies the externalized parameter value.") | ||||
|  | ||||
| 	cmd.MarkFlagRequired("username") | ||||
| 	cmd.MarkFlagRequired("password") | ||||
| 	cmd.MarkFlagRequired("apiServiceKey") | ||||
| 	cmd.MarkFlagRequired("integrationFlowId") | ||||
| 	cmd.MarkFlagRequired("integrationFlowVersion") | ||||
| 	cmd.MarkFlagRequired("host") | ||||
| 	cmd.MarkFlagRequired("oAuthTokenProviderUrl") | ||||
| 	cmd.MarkFlagRequired("parameterKey") | ||||
| 	cmd.MarkFlagRequired("parameterValue") | ||||
| } | ||||
| @@ -132,38 +122,23 @@ func integrationArtifactUpdateConfigurationMetadata() config.StepData { | ||||
| 		Spec: config.StepSpec{ | ||||
| 			Inputs: config.StepInputs{ | ||||
| 				Secrets: []config.StepSecrets{ | ||||
| 					{Name: "cpiCredentialsId", Description: "Jenkins credentials ID containing username and password for authentication to the SAP Cloud Platform Integration API's", Type: "jenkins"}, | ||||
| 					{Name: "cpiAPIServiceKeyCredentialId", Description: "Jenkins credential ID for secret text containing the service key to the SAP Cloud Integration API", Type: "jenkins"}, | ||||
| 				}, | ||||
| 				Parameters: []config.StepParameters{ | ||||
| 					{ | ||||
| 						Name: "username", | ||||
| 						Name: "apiServiceKey", | ||||
| 						ResourceRef: []config.ResourceReference{ | ||||
| 							{ | ||||
| 								Name:  "cpiCredentialsId", | ||||
| 								Param: "username", | ||||
| 								Name:  "cpiServiceKeyCredentialId", | ||||
| 								Param: "serviceKey", | ||||
| 								Type:  "secret", | ||||
| 							}, | ||||
| 						}, | ||||
| 						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Scope:     []string{"PARAMETERS"}, | ||||
| 						Type:      "string", | ||||
| 						Mandatory: true, | ||||
| 						Aliases:   []config.Alias{}, | ||||
| 						Default:   os.Getenv("PIPER_username"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name: "password", | ||||
| 						ResourceRef: []config.ResourceReference{ | ||||
| 							{ | ||||
| 								Name:  "cpiCredentialsId", | ||||
| 								Param: "password", | ||||
| 								Type:  "secret", | ||||
| 							}, | ||||
| 						}, | ||||
| 						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:      "string", | ||||
| 						Mandatory: true, | ||||
| 						Aliases:   []config.Alias{}, | ||||
| 						Default:   os.Getenv("PIPER_password"), | ||||
| 						Default:   os.Getenv("PIPER_apiServiceKey"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "integrationFlowId", | ||||
| @@ -192,24 +167,6 @@ func integrationArtifactUpdateConfigurationMetadata() config.StepData { | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_platform"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "host", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   true, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_host"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "oAuthTokenProviderUrl", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   true, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_oAuthTokenProviderUrl"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "parameterKey", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
|   | ||||
| @@ -22,11 +22,16 @@ func TestRunIntegrationArtifactUpdateConfiguration(t *testing.T) { | ||||
| 	t.Parallel() | ||||
|  | ||||
| 	t.Run("Successfully update of Integration Flow configuration parameter test", func(t *testing.T) { | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
| 		config := integrationArtifactUpdateConfigurationOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			ParameterKey:           "myheader", | ||||
| @@ -51,11 +56,16 @@ func TestRunIntegrationArtifactUpdateConfiguration(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	t.Run("Failed case of Integration Flow configuration parameter Test", func(t *testing.T) { | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
| 		config := integrationArtifactUpdateConfigurationOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			ParameterKey:           "myheader", | ||||
| @@ -69,11 +79,16 @@ func TestRunIntegrationArtifactUpdateConfiguration(t *testing.T) { | ||||
| 	}) | ||||
|  | ||||
| 	t.Run("Failed case of Integration Flow configuration parameter test with error body", func(t *testing.T) { | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
| 		config := integrationArtifactUpdateConfigurationOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowID:      "flow1", | ||||
| 			IntegrationFlowVersion: "1.0.1", | ||||
| 			ParameterKey:           "myheader", | ||||
|   | ||||
| @@ -64,11 +64,17 @@ func integrationArtifactUpload(config integrationArtifactUploadOptions, telemetr | ||||
| } | ||||
|  | ||||
| func runIntegrationArtifactUpload(config *integrationArtifactUploadOptions, telemetryData *telemetry.CustomData, fileUtils piperutils.FileUtils, httpClient piperhttp.Sender) error { | ||||
|  | ||||
| 	serviceKey, err := cpi.ReadCpiServiceKey(config.APIServiceKey) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	clientOptions := piperhttp.ClientOptions{} | ||||
| 	header := make(http.Header) | ||||
| 	header.Add("Accept", "application/json") | ||||
| 	iFlowStatusServiceURL := fmt.Sprintf("%s/api/v1/IntegrationDesigntimeArtifacts(Id='%s',Version='%s')", config.Host, config.IntegrationFlowID, config.IntegrationFlowVersion) | ||||
| 	tokenParameters := cpi.TokenParameters{TokenURL: config.OAuthTokenProviderURL, Username: config.Username, Password: config.Password, Client: httpClient} | ||||
| 	iFlowStatusServiceURL := fmt.Sprintf("%s/api/v1/IntegrationDesigntimeArtifacts(Id='%s',Version='%s')", serviceKey.OAuth.Host, config.IntegrationFlowID, config.IntegrationFlowVersion) | ||||
| 	tokenParameters := cpi.TokenParameters{TokenURL: serviceKey.OAuth.OAuthTokenProviderURL, Username: serviceKey.OAuth.ClientID, Password: serviceKey.OAuth.ClientSecret, Client: httpClient} | ||||
| 	token, err := cpi.CommonUtils.GetBearerToken(tokenParameters) | ||||
| 	if err != nil { | ||||
| 		return errors.Wrap(err, "failed to fetch Bearer Token") | ||||
| @@ -84,9 +90,9 @@ func runIntegrationArtifactUpload(config *integrationArtifactUploadOptions, tele | ||||
| 		defer iFlowStatusResp.Body.Close() | ||||
| 	} | ||||
| 	if iFlowStatusResp.StatusCode == 200 { | ||||
| 		return UpdateIntegrationArtifact(config, httpClient, fileUtils) | ||||
| 		return UpdateIntegrationArtifact(config, httpClient, fileUtils, serviceKey.OAuth.Host) | ||||
| 	} else if httpErr != nil && iFlowStatusResp.StatusCode == 404 { | ||||
| 		return UploadIntegrationArtifact(config, httpClient, fileUtils) | ||||
| 		return UploadIntegrationArtifact(config, httpClient, fileUtils, serviceKey.OAuth.Host) | ||||
| 	} | ||||
|  | ||||
| 	if iFlowStatusResp == nil { | ||||
| @@ -105,9 +111,9 @@ func runIntegrationArtifactUpload(config *integrationArtifactUploadOptions, tele | ||||
| } | ||||
|  | ||||
| //UploadIntegrationArtifact - Upload new integration artifact | ||||
| func UploadIntegrationArtifact(config *integrationArtifactUploadOptions, httpClient piperhttp.Sender, fileUtils piperutils.FileUtils) error { | ||||
| func UploadIntegrationArtifact(config *integrationArtifactUploadOptions, httpClient piperhttp.Sender, fileUtils piperutils.FileUtils, apiHost string) error { | ||||
| 	httpMethod := "POST" | ||||
| 	uploadIflowStatusURL := fmt.Sprintf("%s/api/v1/IntegrationDesigntimeArtifacts", config.Host) | ||||
| 	uploadIflowStatusURL := fmt.Sprintf("%s/api/v1/IntegrationDesigntimeArtifacts", apiHost) | ||||
| 	header := make(http.Header) | ||||
| 	header.Add("content-type", "application/json") | ||||
| 	payload, jsonError := GetJSONPayloadAsByteArray(config, "create", fileUtils) | ||||
| @@ -143,11 +149,11 @@ func UploadIntegrationArtifact(config *integrationArtifactUploadOptions, httpCli | ||||
| } | ||||
|  | ||||
| //UpdateIntegrationArtifact - Update existing integration artifact | ||||
| func UpdateIntegrationArtifact(config *integrationArtifactUploadOptions, httpClient piperhttp.Sender, fileUtils piperutils.FileUtils) error { | ||||
| func UpdateIntegrationArtifact(config *integrationArtifactUploadOptions, httpClient piperhttp.Sender, fileUtils piperutils.FileUtils, apiHost string) error { | ||||
| 	httpMethod := "POST" | ||||
| 	header := make(http.Header) | ||||
| 	header.Add("content-type", "application/json") | ||||
| 	updateIflowStatusURL := fmt.Sprintf("%s/api/v1/IntegrationDesigntimeArtifactSaveAsVersion?Id='%s'&SaveAsVersion='%s'", config.Host, config.IntegrationFlowID, config.IntegrationFlowVersion) | ||||
| 	updateIflowStatusURL := fmt.Sprintf("%s/api/v1/IntegrationDesigntimeArtifactSaveAsVersion?Id='%s'&SaveAsVersion='%s'", apiHost, config.IntegrationFlowID, config.IntegrationFlowVersion) | ||||
| 	payload, jsonError := GetJSONPayloadAsByteArray(config, "update", fileUtils) | ||||
| 	if jsonError != nil { | ||||
| 		return errors.Wrapf(jsonError, "Failed to get json payload for file %v, failed with error", config.FilePath) | ||||
|   | ||||
| @@ -15,14 +15,11 @@ import ( | ||||
| ) | ||||
|  | ||||
| type integrationArtifactUploadOptions struct { | ||||
| 	Username               string `json:"username,omitempty"` | ||||
| 	Password               string `json:"password,omitempty"` | ||||
| 	APIServiceKey          string `json:"apiServiceKey,omitempty"` | ||||
| 	IntegrationFlowID      string `json:"integrationFlowId,omitempty"` | ||||
| 	IntegrationFlowVersion string `json:"integrationFlowVersion,omitempty"` | ||||
| 	IntegrationFlowName    string `json:"integrationFlowName,omitempty"` | ||||
| 	PackageID              string `json:"packageId,omitempty"` | ||||
| 	Host                   string `json:"host,omitempty"` | ||||
| 	OAuthTokenProviderURL  string `json:"oAuthTokenProviderUrl,omitempty"` | ||||
| 	FilePath               string `json:"filePath,omitempty"` | ||||
| } | ||||
|  | ||||
| @@ -53,8 +50,7 @@ func IntegrationArtifactUploadCommand() *cobra.Command { | ||||
| 				log.SetErrorCategory(log.ErrorConfiguration) | ||||
| 				return err | ||||
| 			} | ||||
| 			log.RegisterSecret(stepConfig.Username) | ||||
| 			log.RegisterSecret(stepConfig.Password) | ||||
| 			log.RegisterSecret(stepConfig.APIServiceKey) | ||||
|  | ||||
| 			if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 { | ||||
| 				sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID) | ||||
| @@ -101,24 +97,18 @@ func IntegrationArtifactUploadCommand() *cobra.Command { | ||||
| } | ||||
|  | ||||
| func addIntegrationArtifactUploadFlags(cmd *cobra.Command, stepConfig *integrationArtifactUploadOptions) { | ||||
| 	cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User to authenticate to the SAP Cloud Platform Integration Service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password to authenticate to the SAP Cloud Platform Integration Service") | ||||
| 	cmd.Flags().StringVar(&stepConfig.APIServiceKey, "apiServiceKey", os.Getenv("PIPER_apiServiceKey"), "Service key JSON string to access the Cloud Integration API") | ||||
| 	cmd.Flags().StringVar(&stepConfig.IntegrationFlowID, "integrationFlowId", os.Getenv("PIPER_integrationFlowId"), "Specifies the ID of the Integration Flow artifact") | ||||
| 	cmd.Flags().StringVar(&stepConfig.IntegrationFlowVersion, "integrationFlowVersion", os.Getenv("PIPER_integrationFlowVersion"), "Specifies the version of the Integration Flow artifact") | ||||
| 	cmd.Flags().StringVar(&stepConfig.IntegrationFlowName, "integrationFlowName", os.Getenv("PIPER_integrationFlowName"), "Specifies the Name of the Integration Flow artifact") | ||||
| 	cmd.Flags().StringVar(&stepConfig.PackageID, "packageId", os.Getenv("PIPER_packageId"), "Specifies the ID of the Integration Package") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Host, "host", os.Getenv("PIPER_host"), "Specifies the protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.") | ||||
| 	cmd.Flags().StringVar(&stepConfig.OAuthTokenProviderURL, "oAuthTokenProviderUrl", os.Getenv("PIPER_oAuthTokenProviderUrl"), "Specifies the oAuth Provider protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`.") | ||||
| 	cmd.Flags().StringVar(&stepConfig.FilePath, "filePath", os.Getenv("PIPER_filePath"), "Specifies integration artifact relative file path.") | ||||
|  | ||||
| 	cmd.MarkFlagRequired("username") | ||||
| 	cmd.MarkFlagRequired("password") | ||||
| 	cmd.MarkFlagRequired("apiServiceKey") | ||||
| 	cmd.MarkFlagRequired("integrationFlowId") | ||||
| 	cmd.MarkFlagRequired("integrationFlowVersion") | ||||
| 	cmd.MarkFlagRequired("integrationFlowName") | ||||
| 	cmd.MarkFlagRequired("packageId") | ||||
| 	cmd.MarkFlagRequired("host") | ||||
| 	cmd.MarkFlagRequired("oAuthTokenProviderUrl") | ||||
| 	cmd.MarkFlagRequired("filePath") | ||||
| } | ||||
|  | ||||
| @@ -133,38 +123,23 @@ func integrationArtifactUploadMetadata() config.StepData { | ||||
| 		Spec: config.StepSpec{ | ||||
| 			Inputs: config.StepInputs{ | ||||
| 				Secrets: []config.StepSecrets{ | ||||
| 					{Name: "cpiCredentialsId", Description: "Jenkins credentials ID containing username and password for authentication to the SAP Cloud Platform Integration API's", Type: "jenkins"}, | ||||
| 					{Name: "cpiAPIServiceKeyCredentialId", Description: "Jenkins credential ID for secret text containing the service key to the SAP Cloud Integration API", Type: "jenkins"}, | ||||
| 				}, | ||||
| 				Parameters: []config.StepParameters{ | ||||
| 					{ | ||||
| 						Name: "username", | ||||
| 						Name: "apiServiceKey", | ||||
| 						ResourceRef: []config.ResourceReference{ | ||||
| 							{ | ||||
| 								Name:  "cpiCredentialsId", | ||||
| 								Param: "username", | ||||
| 								Name:  "cpiServiceKeyCredentialId", | ||||
| 								Param: "serviceKey", | ||||
| 								Type:  "secret", | ||||
| 							}, | ||||
| 						}, | ||||
| 						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Scope:     []string{"PARAMETERS"}, | ||||
| 						Type:      "string", | ||||
| 						Mandatory: true, | ||||
| 						Aliases:   []config.Alias{}, | ||||
| 						Default:   os.Getenv("PIPER_username"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name: "password", | ||||
| 						ResourceRef: []config.ResourceReference{ | ||||
| 							{ | ||||
| 								Name:  "cpiCredentialsId", | ||||
| 								Param: "password", | ||||
| 								Type:  "secret", | ||||
| 							}, | ||||
| 						}, | ||||
| 						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:      "string", | ||||
| 						Mandatory: true, | ||||
| 						Aliases:   []config.Alias{}, | ||||
| 						Default:   os.Getenv("PIPER_password"), | ||||
| 						Default:   os.Getenv("PIPER_apiServiceKey"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "integrationFlowId", | ||||
| @@ -202,24 +177,6 @@ func integrationArtifactUploadMetadata() config.StepData { | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_packageId"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "host", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   true, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_host"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "oAuthTokenProviderUrl", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "string", | ||||
| 						Mandatory:   true, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     os.Getenv("PIPER_oAuthTokenProviderUrl"), | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "filePath", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
|   | ||||
| @@ -32,11 +32,17 @@ func TestRunIntegrationArtifactUpload(t *testing.T) { | ||||
| 		assert.NoError(t, err) | ||||
| 		assert.True(t, exists) | ||||
|  | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
|  | ||||
| 		config := integrationArtifactUploadOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowName:    "flow4", | ||||
| 			IntegrationFlowID:      "flow4", | ||||
| 			IntegrationFlowVersion: "1.0.4", | ||||
| @@ -68,11 +74,16 @@ func TestRunIntegrationArtifactUpload(t *testing.T) { | ||||
| 		exists, err := files.FileExists(path) | ||||
| 		assert.NoError(t, err) | ||||
| 		assert.True(t, exists) | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
| 		config := integrationArtifactUploadOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowName:    "flow4", | ||||
| 			IntegrationFlowID:      "flow4", | ||||
| 			IntegrationFlowVersion: "1.0.4", | ||||
| @@ -98,11 +109,16 @@ func TestRunIntegrationArtifactUpload(t *testing.T) { | ||||
|  | ||||
| 	t.Run("Failed case of Integration Flow Get Test", func(t *testing.T) { | ||||
|  | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
| 		config := integrationArtifactUploadOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowName:    "flow4", | ||||
| 			IntegrationFlowID:      "flow4", | ||||
| 			IntegrationFlowVersion: "1.0.4", | ||||
| @@ -124,11 +140,16 @@ func TestRunIntegrationArtifactUpload(t *testing.T) { | ||||
| 		assert.NoError(t, err) | ||||
| 		assert.True(t, exists) | ||||
|  | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
| 		config := integrationArtifactUploadOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowName:    "flow4", | ||||
| 			IntegrationFlowID:      "flow4", | ||||
| 			IntegrationFlowVersion: "1.0.4", | ||||
| @@ -150,11 +171,16 @@ func TestRunIntegrationArtifactUpload(t *testing.T) { | ||||
| 		assert.NoError(t, err) | ||||
| 		assert.True(t, exists) | ||||
|  | ||||
| 		apiServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 			} | ||||
| 		}` | ||||
| 		config := integrationArtifactUploadOptions{ | ||||
| 			Host:                   "https://demo", | ||||
| 			OAuthTokenProviderURL:  "https://demo/oauth/token", | ||||
| 			Username:               "demouser", | ||||
| 			Password:               "******", | ||||
| 			APIServiceKey:          apiServiceKey, | ||||
| 			IntegrationFlowName:    "flow4", | ||||
| 			IntegrationFlowID:      "flow4", | ||||
| 			IntegrationFlowVersion: "1.0.4", | ||||
|   | ||||
| @@ -24,10 +24,8 @@ Example of a YAML configuration file (such as `.pipeline/config.yaml`). | ||||
| steps: | ||||
|   <...> | ||||
|   integrationArtifactDeploy: | ||||
|     cpiCredentialsId: 'MY_CPI_OAUTH_CREDENTIALSID_IN_JENKINS' | ||||
|     cpiAPIServiceKeyCredentialId: 'MY_API_SERVICE_KEY' | ||||
|     integrationFlowId: 'MY_INTEGRATION_FLOW_NAME' | ||||
|     integrationFlowVersion: 'MY_INTEGRATION_FLOW_VERSION' | ||||
|     platform: cf | ||||
|     host: https://CPI_HOST_ITSPACES_URL | ||||
|     oAuthTokenProviderUrl: https://CPI_HOST_OAUTH_URL | ||||
| ``` | ||||
|   | ||||
| @@ -24,10 +24,8 @@ Example for the use in a YAML configuration file (such as `.pipeline/config.yaml | ||||
| steps: | ||||
|   <...> | ||||
|   integrationArtifactDownload: | ||||
|     cpiCredentialsId: 'MY_CPI_OAUTH_CREDENTIALSID_IN_JENKINS' | ||||
|     cpiAPIServiceKeyCredentialId: 'MY_API_SERVICE_KEY' | ||||
|     integrationFlowId: 'MY_INTEGRATION_FLOW_NAME' | ||||
|     integrationFlowVersion: 'MY_INTEGRATION_FLOW_VERSION' | ||||
|     host: https://CPI_HOST_ITSPACES_URL | ||||
|     oAuthTokenProviderUrl: https://CPI_HOST_OAUTH_URL | ||||
|     downloadPath: MY_INTEGRATION_FLOW_DOWNLOAD_PATH | ||||
| ``` | ||||
|   | ||||
| @@ -24,9 +24,7 @@ Example for the use in a YAML configuration file (such as `.pipeline/config.yaml | ||||
| steps: | ||||
|   <...> | ||||
|   integrationArtifactGetMplStatus: | ||||
|     cpiCredentialsId: 'MY_CPI_OAUTH_CREDENTIALSID_IN_JENKINS' | ||||
|     cpiAPIServiceKeyCredentialId: 'MY_API_SERVICE_KEY' | ||||
|     integrationFlowId: 'INTEGRATION_FLOW_ID' | ||||
|     platform: cf | ||||
|     host: https://CPI_HOST_ITSPACES_URL | ||||
|     oAuthTokenProviderUrl: https://CPI_HOST_OAUTH_URL | ||||
| ``` | ||||
|   | ||||
| @@ -24,9 +24,7 @@ Example for the use in a YAML configuration file (such as `.pipeline/config.yaml | ||||
| steps: | ||||
|   <...> | ||||
|   integrationArtifactGetServiceEndpoint: | ||||
|     cpiCredentialsId: 'MY_CPI_OAUTH_CREDENTIALSID_IN_JENKINS' | ||||
|     cpiAPIServiceKeyCredentialId: 'MY_API_SERVICE_KEY' | ||||
|     integrationFlowId: 'MY_INTEGRATION_FLOW_ID' | ||||
|     platform: cf | ||||
|     host: https://CPI_HOST_ITSPACES_URL | ||||
|     oAuthTokenProviderUrl: https://CPI_HOST_OAUTH_URL | ||||
| ``` | ||||
|   | ||||
| @@ -24,12 +24,10 @@ Example of a YAML configuration file (such as `.pipeline/config.yaml`). | ||||
| steps: | ||||
|   <...> | ||||
|   integrationArtifactUpdateConfiguration: | ||||
|     cpiCredentialsId: 'MY_CPI_OAUTH_CREDENTIALSID_IN_JENKINS' | ||||
|     cpiAPIServiceKeyCredentialId: 'MY_API_SERVICE_KEY' | ||||
|     integrationFlowId: 'MY_INTEGRATION_FLOW_NAME' | ||||
|     integrationFlowVersion: 'MY_INTEGRATION_FLOW_VERSION' | ||||
|     platform: 'cf' | ||||
|     host: 'https://CPI_HOST_ITSPACES_URL' | ||||
|     oAuthTokenProviderUrl: 'https://CPI_HOST_OAUTH_URL' | ||||
|     parameterKey: 'MY_INTEGRATION_FLOW_CONFIG_PARAMETER_NAME' | ||||
|     parameterValue: 'MY_INTEGRATION_FLOW_CONFIG_PARAMETER_VALUE' | ||||
| ``` | ||||
|   | ||||
| @@ -24,13 +24,11 @@ Example for the use in a YAML configuration file (such as `.pipeline/config.yaml | ||||
| steps: | ||||
|   <...> | ||||
|   integrationArtifactUpload: | ||||
|     cpiCredentialsId: 'MY_CPI_OAUTH_CREDENTIALSID_IN_JENKINS' | ||||
|     cpiAPIServiceKeyCredentialId: 'MY_API_SERVICE_KEY' | ||||
|     integrationFlowId: 'MY_INTEGRATION_FLOW_ID' | ||||
|     integrationFlowVersion: 'MY_INTEGRATION_FLOW_VERSION' | ||||
|     integrationFlowName: 'MY_INTEGRATION_FLOW_Name' | ||||
|     packageId: 'MY_INTEGRATION_Package_ID' | ||||
|     filePath: 'MY_INTEGRATION_FLOW_Artifact_Relative_Path' | ||||
|     host: https://CPI_HOST_ITSPACES_URL | ||||
|     oAuthTokenProviderUrl: https://CPI_HOST_OAUTH_URL | ||||
|     downloadPath: /MY_INTEGRATION_FLOW_DOWNLOAD_PATH | ||||
| ``` | ||||
|   | ||||
| @@ -1,7 +1,9 @@ | ||||
| package cpi | ||||
|  | ||||
| import ( | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"github.com/SAP/jenkins-library/pkg/log" | ||||
| 	"io/ioutil" | ||||
| 	"net/http" | ||||
|  | ||||
| @@ -21,6 +23,32 @@ type TokenParameters struct { | ||||
| 	Client                       piperhttp.Sender | ||||
| } | ||||
|  | ||||
| // ServiceKey contains information about a CPI service key | ||||
| type ServiceKey struct { | ||||
| 	OAuth OAuth `json:"oauth"` | ||||
| } | ||||
|  | ||||
| // OAuth is inside a CPI service key and contains more needed information | ||||
| type OAuth struct { | ||||
| 	Host                  string `json:"url"` | ||||
| 	OAuthTokenProviderURL string `json:"tokenurl"` | ||||
| 	ClientID              string `json:"clientid"` | ||||
| 	ClientSecret          string `json:"clientsecret"` | ||||
| } | ||||
|  | ||||
| // ReadCpiServiceKey unmarshalls the give json service key string. | ||||
| func ReadCpiServiceKey(serviceKeyJSON string) (cpiServiceKey ServiceKey, err error) { | ||||
| 	// parse | ||||
| 	err = json.Unmarshal([]byte(serviceKeyJSON), &cpiServiceKey) | ||||
| 	if err != nil { | ||||
| 		err = errors.Wrap(err, "error unmarshalling serviceKey") | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	log.Entry().Info("CPI serviceKey read successfully") | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // GetBearerToken -Provides the bearer token for making CPI OData calls | ||||
| func (tokenParameters TokenParameters) GetBearerToken() (string, error) { | ||||
|  | ||||
|   | ||||
							
								
								
									
										54
									
								
								pkg/cpi/commonUtils_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								pkg/cpi/commonUtils_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,54 @@ | ||||
| package cpi | ||||
|  | ||||
| import ( | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| 	"testing" | ||||
| ) | ||||
|  | ||||
| func TestReadCpiServiceKeyFile(t *testing.T) { | ||||
| 	properServiceKey := `{ | ||||
| 			"oauth": { | ||||
| 				"url": "https://demo", | ||||
| 				"clientid": "demouser", | ||||
| 				"clientsecret": "******", | ||||
| 				"tokenurl": "https://demo/oauth/token" | ||||
| 				} | ||||
| 			}` | ||||
| 	faultyServiceKey := `this is not json` | ||||
|  | ||||
| 	tests := []struct { | ||||
| 		name              string | ||||
| 		serviceKey        string | ||||
| 		wantCpiServiceKey ServiceKey | ||||
| 		wantedErrorMsg    string | ||||
| 	}{ | ||||
| 		{ | ||||
| 			"happy path", | ||||
| 			properServiceKey, | ||||
| 			ServiceKey{ | ||||
| 				OAuth: OAuth{ | ||||
| 					Host:                  "https://demo", | ||||
| 					OAuthTokenProviderURL: "https://demo/oauth/token", | ||||
| 					ClientID:              "demouser", | ||||
| 					ClientSecret:          "******", | ||||
| 				}, | ||||
| 			}, | ||||
| 			"", | ||||
| 		}, | ||||
| 		{ | ||||
| 			"faulty json", | ||||
| 			faultyServiceKey, | ||||
| 			ServiceKey{}, | ||||
| 			"error unmarshalling serviceKey: invalid character 'h' in literal true (expecting 'r')", | ||||
| 		}, | ||||
| 	} | ||||
| 	for _, tt := range tests { | ||||
| 		t.Run(tt.name, func(t *testing.T) { | ||||
| 			gotCpiServiceKey, err := ReadCpiServiceKey(tt.serviceKey) | ||||
| 			if tt.wantedErrorMsg != "" { | ||||
| 				assert.EqualError(t, err, tt.wantedErrorMsg) | ||||
| 			} | ||||
| 			assert.Equal(t, tt.wantCpiServiceKey, gotCpiServiceKey) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
| @@ -7,36 +7,21 @@ metadata: | ||||
| spec: | ||||
|   inputs: | ||||
|     secrets: | ||||
|       - name: cpiCredentialsId | ||||
|         description: Jenkins credentials ID containing username and password for authentication to the SAP Cloud Platform Integration API's | ||||
|       - name: cpiAPIServiceKeyCredentialId | ||||
|         description: Jenkins credential ID for secret text containing the service key to the SAP Cloud Integration API | ||||
|         type: jenkins | ||||
|     params: | ||||
|       - name: username | ||||
|       - name: apiServiceKey | ||||
|         type: string | ||||
|         description: User to authenticate to the SAP Cloud Platform Integration Service | ||||
|         description: Service key JSON string to access the Cloud Integration API | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|         secret: true | ||||
|         resourceRef: | ||||
|           - name: cpiCredentialsId | ||||
|           - name: cpiServiceKeyCredentialId | ||||
|             type: secret | ||||
|             param: username | ||||
|       - name: password | ||||
|         type: string | ||||
|         description: Password to authenticate to the SAP Cloud Platform Integration Service | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|         secret: true | ||||
|         resourceRef: | ||||
|           - name: cpiCredentialsId | ||||
|             type: secret | ||||
|             param: password | ||||
|             param: serviceKey | ||||
|       - name: integrationFlowId | ||||
|         type: string | ||||
|         description: Specifies the ID of the Integration Flow artifact | ||||
| @@ -61,19 +46,3 @@ spec: | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: false | ||||
|       - name: host | ||||
|         type: string | ||||
|         description: Specifies the protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`. | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|       - name: oAuthTokenProviderUrl | ||||
|         type: string | ||||
|         description: Specifies the oAuth Provider protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`. | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|   | ||||
| @@ -7,36 +7,21 @@ metadata: | ||||
| spec: | ||||
|   inputs: | ||||
|     secrets: | ||||
|       - name: cpiCredentialsId | ||||
|         description: Jenkins credentials ID containing username and password for authentication to the SAP Cloud Platform Integration API's | ||||
|       - name: cpiAPIServiceKeyCredentialId | ||||
|         description: Jenkins credential ID for secret text containing the service key to the SAP Cloud Integration API | ||||
|         type: jenkins | ||||
|     params: | ||||
|       - name: username | ||||
|       - name: apiServiceKey | ||||
|         type: string | ||||
|         description: User to authenticate to the SAP Cloud Platform Integration Service | ||||
|         description: Service key JSON string to access the Cloud Integration API | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|         secret: true | ||||
|         resourceRef: | ||||
|           - name: cpiCredentialsId | ||||
|           - name: cpiServiceKeyCredentialId | ||||
|             type: secret | ||||
|             param: username | ||||
|       - name: password | ||||
|         type: string | ||||
|         description: Password to authenticate to the SAP Cloud Platform Integration Service | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|         secret: true | ||||
|         resourceRef: | ||||
|           - name: cpiCredentialsId | ||||
|             type: secret | ||||
|             param: password | ||||
|             param: serviceKey | ||||
|       - name: integrationFlowId | ||||
|         type: string | ||||
|         description: Specifies the ID of the Integration Flow artifact | ||||
| @@ -53,22 +38,6 @@ spec: | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|       - name: host | ||||
|         type: string | ||||
|         description: Specifies the protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`. | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|       - name: oAuthTokenProviderUrl | ||||
|         type: string | ||||
|         description: Specifies the oAuth Provider protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`. | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|       - name: downloadPath | ||||
|         type: string | ||||
|         description: Specifies integration artifact download location. | ||||
|   | ||||
| @@ -7,36 +7,21 @@ metadata: | ||||
| spec: | ||||
|   inputs: | ||||
|     secrets: | ||||
|       - name: cpiCredentialsId | ||||
|         description: Jenkins credentials ID containing username and password for authentication to the SAP Cloud Platform Integration API's | ||||
|       - name: cpiAPIServiceKeyCredentialId | ||||
|         description: Jenkins credential ID for secret text containing the service key to the SAP Cloud Integration API | ||||
|         type: jenkins | ||||
|     params: | ||||
|       - name: username | ||||
|       - name: apiServiceKey | ||||
|         type: string | ||||
|         description: User to authenticate to the SAP Cloud Platform Integration Service | ||||
|         description: Service key JSON string to access the Cloud Integration API | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|         secret: true | ||||
|         resourceRef: | ||||
|           - name: cpiCredentialsId | ||||
|           - name: cpiServiceKeyCredentialId | ||||
|             type: secret | ||||
|             param: username | ||||
|       - name: password | ||||
|         type: string | ||||
|         description: Password to authenticate to the SAP Cloud Platform Integration Service | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|         secret: true | ||||
|         resourceRef: | ||||
|           - name: cpiCredentialsId | ||||
|             type: secret | ||||
|             param: password | ||||
|             param: serviceKey | ||||
|       - name: integrationFlowId | ||||
|         type: string | ||||
|         description: Specifies the ID of the Integration Flow artifact | ||||
| @@ -53,22 +38,6 @@ spec: | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: false | ||||
|       - name: host | ||||
|         type: string | ||||
|         description: Specifies the protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`. | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|       - name: oAuthTokenProviderUrl | ||||
|         type: string | ||||
|         description: Specifies the oAuth Provider protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`. | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|   outputs: | ||||
|     resources: | ||||
|       - name: commonPipelineEnvironment | ||||
|   | ||||
| @@ -7,36 +7,21 @@ metadata: | ||||
| spec: | ||||
|   inputs: | ||||
|     secrets: | ||||
|       - name: cpiCredentialsId | ||||
|         description: Jenkins credentials ID containing username and password for authentication to the SAP Cloud Platform Integration API's | ||||
|       - name: cpiAPIServiceKeyCredentialId | ||||
|         description: Jenkins credential ID for secret text containing the service key to the SAP Cloud Integration API | ||||
|         type: jenkins | ||||
|     params: | ||||
|       - name: username | ||||
|       - name: apiServiceKey | ||||
|         type: string | ||||
|         description: User to authenticate to the SAP Cloud Platform Integration Service | ||||
|         description: Service key JSON string to access the Cloud Integration API | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|         secret: true | ||||
|         resourceRef: | ||||
|           - name: cpiCredentialsId | ||||
|           - name: cpiServiceKeyCredentialId | ||||
|             type: secret | ||||
|             param: username | ||||
|       - name: password | ||||
|         type: string | ||||
|         description: Password to authenticate to the SAP Cloud Platform Integration Service | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|         secret: true | ||||
|         resourceRef: | ||||
|           - name: cpiCredentialsId | ||||
|             type: secret | ||||
|             param: password | ||||
|             param: serviceKey | ||||
|       - name: integrationFlowId | ||||
|         type: string | ||||
|         description: Specifies the ID of the Integration Flow artifact | ||||
| @@ -53,22 +38,6 @@ spec: | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: false | ||||
|       - name: host | ||||
|         type: string | ||||
|         description: Specifies the protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`. | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|       - name: oAuthTokenProviderUrl | ||||
|         type: string | ||||
|         description: Specifies the oAuth Provider protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`. | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|   outputs: | ||||
|     resources: | ||||
|       - name: commonPipelineEnvironment | ||||
|   | ||||
| @@ -7,36 +7,21 @@ metadata: | ||||
| spec: | ||||
|   inputs: | ||||
|     secrets: | ||||
|       - name: cpiCredentialsId | ||||
|         description: Jenkins credentials ID containing username and password for authentication to the SAP Cloud Platform Integration API's | ||||
|       - name: cpiAPIServiceKeyCredentialId | ||||
|         description: Jenkins credential ID for secret text containing the service key to the SAP Cloud Integration API | ||||
|         type: jenkins | ||||
|     params: | ||||
|       - name: username | ||||
|       - name: apiServiceKey | ||||
|         type: string | ||||
|         description: User to authenticate to the SAP Cloud Platform Integration Service | ||||
|         description: Service key JSON string to access the Cloud Integration API | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|         secret: true | ||||
|         resourceRef: | ||||
|           - name: cpiCredentialsId | ||||
|           - name: cpiServiceKeyCredentialId | ||||
|             type: secret | ||||
|             param: username | ||||
|       - name: password | ||||
|         type: string | ||||
|         description: Password to authenticate to the SAP Cloud Platform Integration Service | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|         secret: true | ||||
|         resourceRef: | ||||
|           - name: cpiCredentialsId | ||||
|             type: secret | ||||
|             param: password | ||||
|             param: serviceKey | ||||
|       - name: integrationFlowId | ||||
|         type: string | ||||
|         description: Specifies the ID of the Integration Flow artifact | ||||
| @@ -61,22 +46,6 @@ spec: | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: false | ||||
|       - name: host | ||||
|         type: string | ||||
|         description: Specifies the protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`. | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|       - name: oAuthTokenProviderUrl | ||||
|         type: string | ||||
|         description: Specifies the oAuth Provider protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`. | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|       - name: parameterKey | ||||
|         type: string | ||||
|         description: Specifies the externalized parameter name. | ||||
|   | ||||
| @@ -7,36 +7,21 @@ metadata: | ||||
| spec: | ||||
|   inputs: | ||||
|     secrets: | ||||
|       - name: cpiCredentialsId | ||||
|         description: Jenkins credentials ID containing username and password for authentication to the SAP Cloud Platform Integration API's | ||||
|       - name: cpiAPIServiceKeyCredentialId | ||||
|         description: Jenkins credential ID for secret text containing the service key to the SAP Cloud Integration API | ||||
|         type: jenkins | ||||
|     params: | ||||
|       - name: username | ||||
|       - name: apiServiceKey | ||||
|         type: string | ||||
|         description: User to authenticate to the SAP Cloud Platform Integration Service | ||||
|         description: Service key JSON string to access the Cloud Integration API | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|         secret: true | ||||
|         resourceRef: | ||||
|           - name: cpiCredentialsId | ||||
|           - name: cpiServiceKeyCredentialId | ||||
|             type: secret | ||||
|             param: username | ||||
|       - name: password | ||||
|         type: string | ||||
|         description: Password to authenticate to the SAP Cloud Platform Integration Service | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|         secret: true | ||||
|         resourceRef: | ||||
|           - name: cpiCredentialsId | ||||
|             type: secret | ||||
|             param: password | ||||
|             param: serviceKey | ||||
|       - name: integrationFlowId | ||||
|         type: string | ||||
|         description: Specifies the ID of the Integration Flow artifact | ||||
| @@ -69,22 +54,6 @@ spec: | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|       - name: host | ||||
|         type: string | ||||
|         description: Specifies the protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`. | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|       - name: oAuthTokenProviderUrl | ||||
|         type: string | ||||
|         description: Specifies the oAuth Provider protocol and host address, including the port. Please provide in the format `<protocol>://<host>:<port>`. Supported protocols are `http` and `https`. | ||||
|         scope: | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         mandatory: true | ||||
|       - name: filePath | ||||
|         type: string | ||||
|         description: Specifies integration artifact relative file path. | ||||
|   | ||||
| @@ -5,7 +5,7 @@ import groovy.transform.Field | ||||
|  | ||||
| void call(Map parameters = [:]) { | ||||
|     List credentials = [ | ||||
|         [type: 'usernamePassword', id: 'cpiCredentialsId', env: ['PIPER_username', 'PIPER_password']] | ||||
|         [type: 'token', id: 'cpiAPIServiceKeyCredentialId', env: ['PIPER_apiServiceKey']] | ||||
|     ] | ||||
|     piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials) | ||||
| } | ||||
|   | ||||
| @@ -5,7 +5,7 @@ import groovy.transform.Field | ||||
|  | ||||
| void call(Map parameters = [:]) { | ||||
|     List credentials = [ | ||||
|         [type: 'usernamePassword', id: 'cpiCredentialsId', env: ['PIPER_username', 'PIPER_password']] | ||||
|         [type: 'token', id: 'cpiAPIServiceKeyCredentialId', env: ['PIPER_apiServiceKey']] | ||||
|     ] | ||||
|     piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials) | ||||
| } | ||||
|   | ||||
| @@ -5,7 +5,7 @@ import groovy.transform.Field | ||||
|  | ||||
| void call(Map parameters = [:]) { | ||||
|     List credentials = [ | ||||
|         [type: 'usernamePassword', id: 'cpiCredentialsId', env: ['PIPER_username', 'PIPER_password']] | ||||
|         [type: 'token', id: 'cpiAPIServiceKeyCredentialId', env: ['PIPER_apiServiceKey']] | ||||
|     ] | ||||
|     piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials) | ||||
| } | ||||
|   | ||||
| @@ -5,7 +5,7 @@ import groovy.transform.Field | ||||
|  | ||||
| void call(Map parameters = [:]) { | ||||
|     List credentials = [ | ||||
|         [type: 'usernamePassword', id: 'cpiCredentialsId', env: ['PIPER_username', 'PIPER_password']] | ||||
|         [type: 'token', id: 'cpiAPIServiceKeyCredentialId', env: ['PIPER_apiServiceKey']] | ||||
|     ] | ||||
|     piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials) | ||||
| } | ||||
|   | ||||
| @@ -5,7 +5,7 @@ import groovy.transform.Field | ||||
|  | ||||
| void call(Map parameters = [:]) { | ||||
|     List credentials = [ | ||||
|         [type: 'usernamePassword', id: 'cpiCredentialsId', env: ['PIPER_username', 'PIPER_password']] | ||||
|         [type: 'token', id: 'cpiAPIServiceKeyCredentialId', env: ['PIPER_apiServiceKey']] | ||||
|     ] | ||||
|     piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials) | ||||
| } | ||||
|   | ||||
| @@ -5,7 +5,7 @@ import groovy.transform.Field | ||||
|  | ||||
| void call(Map parameters = [:]) { | ||||
|     List credentials = [ | ||||
|         [type: 'usernamePassword', id: 'cpiCredentialsId', env: ['PIPER_username', 'PIPER_password']] | ||||
|         [type: 'token', id: 'cpiAPIServiceKeyCredentialId', env: ['PIPER_apiServiceKey']] | ||||
|     ] | ||||
|     piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user