From 35aad23e8025c47c19d7f73778d020cc5934db3d Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Tue, 11 Jun 2024 13:18:45 +0200 Subject: [PATCH 01/33] adding byog credentials for clone command --- cmd/abapEnvironmentCloneGitRepo.go | 5 +- cmd/abapEnvironmentCloneGitRepo_generated.go | 50 +++++++++++++++++++ pkg/abaputils/abaputils.go | 3 ++ pkg/abaputils/descriptor.go | 3 ++ pkg/abaputils/manageGitRepositoryUtils.go | 18 ++++++- pkg/abaputils/softwareComponentApiManager.go | 3 ++ .../metadata/abapEnvironmentCloneGitRepo.yaml | 42 ++++++++++++++++ vars/abapEnvironmentCloneGitRepo.groovy | 3 +- 8 files changed, 123 insertions(+), 4 deletions(-) diff --git a/cmd/abapEnvironmentCloneGitRepo.go b/cmd/abapEnvironmentCloneGitRepo.go index 687044dd77..b5913dad7e 100644 --- a/cmd/abapEnvironmentCloneGitRepo.go +++ b/cmd/abapEnvironmentCloneGitRepo.go @@ -42,7 +42,7 @@ func runAbapEnvironmentCloneGitRepo(config *abapEnvironmentCloneGitRepoOptions, return errors.Wrap(errConfig, "The provided configuration is not allowed") } - repositories, errGetRepos := abaputils.GetRepositories(&abaputils.RepositoriesConfig{BranchName: config.BranchName, RepositoryName: config.RepositoryName, Repositories: config.Repositories}, false) + repositories, errGetRepos := abaputils.GetRepositories(&abaputils.RepositoriesConfig{BranchName: config.BranchName, RepositoryName: config.RepositoryName, Repositories: config.Repositories, ByogUsername: config.ByogUsername, ByogPassword: config.ByogPassword, ByogAuthMethod: config.ByogAuthMethod}, false) if errGetRepos != nil { return errors.Wrap(errGetRepos, "Could not read repositories") } @@ -186,5 +186,8 @@ func convertCloneConfig(config *abapEnvironmentCloneGitRepoOptions) abaputils.Ab subOptions.Host = config.Host subOptions.Password = config.Password subOptions.Username = config.Username + subOptions.ByogUsername = config.ByogUsername + subOptions.ByogPassword = config.ByogPassword + subOptions.ByogAuthMethod = config.ByogAuthMethod return subOptions } diff --git a/cmd/abapEnvironmentCloneGitRepo_generated.go b/cmd/abapEnvironmentCloneGitRepo_generated.go index 8f37662939..6fe000b86c 100644 --- a/cmd/abapEnvironmentCloneGitRepo_generated.go +++ b/cmd/abapEnvironmentCloneGitRepo_generated.go @@ -18,6 +18,9 @@ import ( type abapEnvironmentCloneGitRepoOptions struct { Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` + ByogPassword string `json:"byogPassword,omitempty"` + ByogUsername string `json:"byogUsername,omitempty"` + ByogAuthMethod string `json:"byogAuthMethod,omitempty"` Repositories string `json:"repositories,omitempty"` RepositoryName string `json:"repositoryName,omitempty"` BranchName string `json:"branchName,omitempty"` @@ -68,6 +71,8 @@ Please provide either of the following options: } log.RegisterSecret(stepConfig.Username) log.RegisterSecret(stepConfig.Password) + log.RegisterSecret(stepConfig.ByogPassword) + log.RegisterSecret(stepConfig.ByogUsername) if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 { sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID) @@ -138,6 +143,9 @@ Please provide either of the following options: func addAbapEnvironmentCloneGitRepoFlags(cmd *cobra.Command, stepConfig *abapEnvironmentCloneGitRepoOptions) { cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0510") cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0510") + cmd.Flags().StringVar(&stepConfig.ByogPassword, "byogPassword", os.Getenv("PIPER_byogPassword"), "Password for bring your own git (BYOG) authentication") + cmd.Flags().StringVar(&stepConfig.ByogUsername, "byogUsername", os.Getenv("PIPER_byogUsername"), "Username for bring your own git (BYOG) authentication") + cmd.Flags().StringVar(&stepConfig.ByogAuthMethod, "byogAuthMethod", os.Getenv("PIPER_byogAuthMethod"), "Specifies which authentication method is used for bring your own git (BYOG) repositories") cmd.Flags().StringVar(&stepConfig.Repositories, "repositories", os.Getenv("PIPER_repositories"), "Specifies a YAML file containing the repositories configuration") cmd.Flags().StringVar(&stepConfig.RepositoryName, "repositoryName", os.Getenv("PIPER_repositoryName"), "Specifies a repository (Software Components) on the SAP BTP ABAP Environment system") cmd.Flags().StringVar(&stepConfig.BranchName, "branchName", os.Getenv("PIPER_branchName"), "Specifies a branch of a repository (Software Components) on the SAP BTP ABAP Environment system") @@ -151,6 +159,8 @@ func addAbapEnvironmentCloneGitRepoFlags(cmd *cobra.Command, stepConfig *abapEnv cmd.MarkFlagRequired("username") cmd.MarkFlagRequired("password") + cmd.MarkFlagRequired("byogPassword") + cmd.MarkFlagRequired("byogUsername") } // retrieve step metadata @@ -165,6 +175,7 @@ func abapEnvironmentCloneGitRepoMetadata() config.StepData { Inputs: config.StepInputs{ Secrets: []config.StepSecrets{ {Name: "abapCredentialsId", Description: "Jenkins credentials ID containing user and password to authenticate to the BTP ABAP Environment system or the Cloud Foundry API", Type: "jenkins", Aliases: []config.Alias{{Name: "cfCredentialsId", Deprecated: false}, {Name: "credentialsId", Deprecated: false}}}, + {Name: "byogCredentialsId", Description: "Jenkins credentials ID containing user and password to authenticate to the for a Software Component which is used in a BYOG szenario", Type: "jenkins", Aliases: []config.Alias{{Name: "cfCredentialsId", Deprecated: false}, {Name: "credentialsId", Deprecated: false}}}, }, Parameters: []config.StepParameters{ { @@ -197,6 +208,45 @@ func abapEnvironmentCloneGitRepoMetadata() config.StepData { Aliases: []config.Alias{}, Default: os.Getenv("PIPER_password"), }, + { + Name: "byogPassword", + ResourceRef: []config.ResourceReference{ + { + Name: "byogCredentialsId", + Param: "byogPassword", + Type: "secret", + }, + }, + Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, + Type: "string", + Mandatory: true, + Aliases: []config.Alias{}, + Default: os.Getenv("PIPER_byogPassword"), + }, + { + Name: "byogUsername", + ResourceRef: []config.ResourceReference{ + { + Name: "byogCredentialsId", + Param: "byogUsername", + Type: "secret", + }, + }, + Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, + Type: "string", + Mandatory: true, + Aliases: []config.Alias{}, + Default: os.Getenv("PIPER_byogUsername"), + }, + { + Name: "byogAuthMethod", + ResourceRef: []config.ResourceReference{}, + Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"}, + Type: "string", + Mandatory: false, + Aliases: []config.Alias{}, + Default: os.Getenv("PIPER_byogAuthMethod"), + }, { Name: "repositories", ResourceRef: []config.ResourceReference{}, diff --git a/pkg/abaputils/abaputils.go b/pkg/abaputils/abaputils.go index 6f3d20bf35..e26f4ce7eb 100644 --- a/pkg/abaputils/abaputils.go +++ b/pkg/abaputils/abaputils.go @@ -285,6 +285,9 @@ type AbapEnvironmentRunATCCheckOptions struct { type AbapEnvironmentOptions struct { Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` + ByogUsername string `json:"byogUsername,omitempty"` + ByogPassword string `json:"byogPassword,omitempty"` + ByogAuthMethod string `json:"byogAuthMethod,omitempty"` Host string `json:"host,omitempty"` CfAPIEndpoint string `json:"cfApiEndpoint,omitempty"` CfOrg string `json:"cfOrg,omitempty"` diff --git a/pkg/abaputils/descriptor.go b/pkg/abaputils/descriptor.go index e2add90192..bf1b3684ff 100644 --- a/pkg/abaputils/descriptor.go +++ b/pkg/abaputils/descriptor.go @@ -41,6 +41,9 @@ type Repository struct { Tag string `json:"tag,omitempty"` Branch string `json:"branch,omitempty"` CommitID string `json:"commitID,omitempty"` + ByogUsername string `json:"byogUsername"` + ByogPassword string `json:"byogPassword"` + ByogAuthMethod string `json:"byogAuthMethod"` VersionYAML string `json:"version,omitempty"` Version string `json:"versionAAK"` AdditionalPiecelist string `json:"additionalPiecelist,omitempty"` diff --git a/pkg/abaputils/manageGitRepositoryUtils.go b/pkg/abaputils/manageGitRepositoryUtils.go index d53755a50e..76fc06e303 100644 --- a/pkg/abaputils/manageGitRepositoryUtils.go +++ b/pkg/abaputils/manageGitRepositoryUtils.go @@ -163,7 +163,7 @@ func printHeader(logEntry LogResultsV2, api SoftwareComponentApiInterface) { } } -// GetRepositories for parsing one or multiple branches and repositories from repositories file or branchName and repositoryName configuration +// GetRepositories for parsing one or multiple branches and repositories from repositories file or branchName and repositoryName configuration func GetRepositories(config *RepositoriesConfig, branchRequired bool) ([]Repository, error) { var repositories = make([]Repository, 0) if reflect.DeepEqual(RepositoriesConfig{}, config) { @@ -210,6 +210,19 @@ func (repo *Repository) GetRequestBodyForCommitOrTag() (requestBodyString string return requestBodyString } +func (repo *Repository) GetRequestBodyForBYOGCredentials() (byogBodyString string) { + if repo.ByogAuthMethod != "" { + byogBodyString += `, "auth_method":"` + repo.ByogAuthMethod + `"` + } + if repo.ByogUsername != "" { + byogBodyString += `, "username":"` + repo.ByogUsername + `"` + } + if repo.ByogPassword != "" { + byogBodyString += `, "password":"` + repo.ByogPassword + `"` + } + return byogBodyString +} + func (repo *Repository) GetLogStringForCommitOrTag() (logString string) { if repo.CommitID != "" { logString = ", commit '" + repo.CommitID + "'" @@ -233,7 +246,8 @@ func (repo *Repository) GetCloneRequestBody() (body string) { log.Entry().WithField("Tag", repo.Tag).WithField("Commit ID", repo.CommitID).Info("The commit ID takes precedence over the tag") } requestBodyString := repo.GetRequestBodyForCommitOrTag() - body = `{"branch_name":"` + repo.Branch + `"` + requestBodyString + `}` + byogBodyString := repo.GetRequestBodyForBYOGCredentials() + body = `{"branch_name":"` + repo.Branch + `"` + requestBodyString + byogBodyString + `}` return body } diff --git a/pkg/abaputils/softwareComponentApiManager.go b/pkg/abaputils/softwareComponentApiManager.go index c4d02e7115..3e3de4e2da 100644 --- a/pkg/abaputils/softwareComponentApiManager.go +++ b/pkg/abaputils/softwareComponentApiManager.go @@ -201,6 +201,9 @@ type RepositoriesConfig struct { BranchName string CommitID string RepositoryName string + ByogUsername string + ByogPassword string + ByogAuthMethod string RepositoryNames []string Repositories string } diff --git a/resources/metadata/abapEnvironmentCloneGitRepo.yaml b/resources/metadata/abapEnvironmentCloneGitRepo.yaml index e4d4035cf0..21e47d2fdf 100644 --- a/resources/metadata/abapEnvironmentCloneGitRepo.yaml +++ b/resources/metadata/abapEnvironmentCloneGitRepo.yaml @@ -18,6 +18,12 @@ spec: aliases: - name: cfCredentialsId - name: credentialsId + - name: byogCredentialsId + description: Jenkins credentials ID containing user and password to authenticate to the for a Software Component which is used in a BYOG szenario + type: jenkins + aliases: + - name: cfCredentialsId + - name: credentialsId params: - name: username type: string @@ -45,6 +51,42 @@ spec: - name: abapCredentialsId type: secret param: password + - name: byogPassword + type: string + description: Password for bring your own git (BYOG) authentication + scope: + - PARAMETERS + - STAGES + - STEPS + - GENERAL + mandatory: true + secret: true + resourceRef: + - name: byogCredentialsId + type: secret + param: byogPassword + - name: byogUsername + type: string + description: Username for bring your own git (BYOG) authentication + scope: + - PARAMETERS + - STAGES + - STEPS + - GENERAL + mandatory: true + secret: true + resourceRef: + - name: byogCredentialsId + type: secret + param: byogUsername + - name: byogAuthMethod + type: string + description: Specifies which authentication method is used for bring your own git (BYOG) repositories + scope: + - PARAMETERS + - STAGES + - STEPS + - GENERAL - name: repositories type: string description: Specifies a YAML file containing the repositories configuration diff --git a/vars/abapEnvironmentCloneGitRepo.groovy b/vars/abapEnvironmentCloneGitRepo.groovy index 96d948cbda..e175316200 100644 --- a/vars/abapEnvironmentCloneGitRepo.groovy +++ b/vars/abapEnvironmentCloneGitRepo.groovy @@ -5,7 +5,8 @@ import groovy.transform.Field void call(Map parameters = [:]) { List credentials = [ - [type: 'usernamePassword', id: 'abapCredentialsId', env: ['PIPER_username', 'PIPER_password']] + [type: 'usernamePassword', id: 'abapCredentialsId', env: ['PIPER_username', 'PIPER_password']], + [type: 'usernamePassword', id: 'byogCredentialsId', env: ['PIPER_boygUsername', 'PIPER_byogPassword']] ] piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials, false, false, true) } From eb16e7c723f1cc36d3343d041b9c42d4616fdda1 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Wed, 12 Jun 2024 10:08:26 +0200 Subject: [PATCH 02/33] adding unit tests for clone body --- pkg/abaputils/abaputils_test.go | 3 --- pkg/abaputils/sap_com_0510_test.go | 3 --- pkg/abaputils/sap_com_0948_test.go | 40 +++++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/pkg/abaputils/abaputils_test.go b/pkg/abaputils/abaputils_test.go index d9b0cafa2d..48ee9aa853 100644 --- a/pkg/abaputils/abaputils_test.go +++ b/pkg/abaputils/abaputils_test.go @@ -1,6 +1,3 @@ -//go:build unit -// +build unit - package abaputils import ( diff --git a/pkg/abaputils/sap_com_0510_test.go b/pkg/abaputils/sap_com_0510_test.go index 28c3af01e6..d18421e3b9 100644 --- a/pkg/abaputils/sap_com_0510_test.go +++ b/pkg/abaputils/sap_com_0510_test.go @@ -1,6 +1,3 @@ -//go:build unit -// +build unit - package abaputils import ( diff --git a/pkg/abaputils/sap_com_0948_test.go b/pkg/abaputils/sap_com_0948_test.go index 8855e994ef..69fe0a0828 100644 --- a/pkg/abaputils/sap_com_0948_test.go +++ b/pkg/abaputils/sap_com_0948_test.go @@ -1,6 +1,3 @@ -//go:build unit -// +build unit - package abaputils import ( @@ -256,6 +253,43 @@ func TestClone0948(t *testing.T) { assert.NoError(t, errClone) assert.Equal(t, "GUID", api.getUUID(), "API does not cotain correct UUID") }) + + t.Run("Test Clone Body Success", func(t *testing.T) { + + cloneBody := []byte(repoTest0948.GetCloneRequestBody()) + assert.Equal(t, "{\"branch_name\":\"main\"}", string(cloneBody), "Clone body is not correct") + }) + + t.Run("Test Clone Body Failure", func(t *testing.T) { + + repoTest0948.Branch = "wrongBranch" + + cloneBody := []byte(repoTest0948.GetCloneRequestBody()) + assert.NotEqual(t, "{\"branch_name\":\"main\"}", string(cloneBody), "Clone body should not match") + + repoTest0948.Branch = "main" + }) + + t.Run("Test Clone Body BYOG Success", func(t *testing.T) { + + repoTest0948.ByogAuthMethod = "token" + repoTest0948.ByogUsername = "byogUser" + repoTest0948.ByogPassword = "byogToken" + + cloneBody := []byte(repoTest0948.GetCloneRequestBody()) + assert.Equal(t, "{\"branch_name\":\"main\", \"auth_method\":\"token\", \"username\":\"byogUser\", \"password\":\"byogToken\"}", string(cloneBody), "Clone body for byog parameter is not correct") + }) + + t.Run("Test Clone Body BYOG Failure", func(t *testing.T) { + + repoTest0948.ByogAuthMethod = "token" + repoTest0948.ByogUsername = "byogUser" + repoTest0948.ByogPassword = "wrongToken" + + cloneBody := []byte(repoTest0948.GetCloneRequestBody()) + assert.NotEqual(t, "{\"branch_name\":\"main\", \"auth_method\":\"token\", \"username\":\"byogUser\", \"password\":\"byogToken\"}", string(cloneBody), "Clone body for byog parameter should not match") + }) + } func TestPull0948(t *testing.T) { From ecf5ffcc8c59be8f5aaec67c18631330708defe0 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Wed, 12 Jun 2024 14:34:13 +0200 Subject: [PATCH 03/33] adding parameters --- pkg/abaputils/manageGitRepositoryUtils.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/abaputils/manageGitRepositoryUtils.go b/pkg/abaputils/manageGitRepositoryUtils.go index 76fc06e303..1d956f2afc 100644 --- a/pkg/abaputils/manageGitRepositoryUtils.go +++ b/pkg/abaputils/manageGitRepositoryUtils.go @@ -193,6 +193,15 @@ func GetRepositories(config *RepositoriesConfig, branchRequired bool) ([]Reposit if config.RepositoryName != "" && !branchRequired { repositories = append(repositories, Repository{Name: config.RepositoryName, CommitID: config.CommitID}) } + if config.ByogAuthMethod != "" { + repositories[0].ByogAuthMethod = config.ByogAuthMethod + } + if config.ByogUsername != "" { + repositories[0].ByogUsername = config.ByogPassword + } + if config.ByogPassword != "" { + repositories[0].ByogPassword = config.ByogPassword + } if len(config.RepositoryNames) > 0 { for _, repository := range config.RepositoryNames { repositories = append(repositories, Repository{Name: repository}) From 1ff6f2f92c784712f409cf2a7453331f38d6c047 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Thu, 13 Jun 2024 16:31:38 +0200 Subject: [PATCH 04/33] adding optional byog parameters --- cmd/abapEnvironmentCloneGitRepo.go | 5 +++- pkg/abaputils/manageGitRepositoryUtils.go | 19 +++++++------- pkg/abaputils/sap_com_0510.go | 23 ++++++++++------- pkg/abaputils/sap_com_0510_test.go | 2 +- pkg/abaputils/sap_com_0948.go | 27 ++++++++++++++------ pkg/abaputils/sap_com_0948_test.go | 2 +- pkg/abaputils/softwareComponentApiManager.go | 4 ++- 7 files changed, 52 insertions(+), 30 deletions(-) diff --git a/cmd/abapEnvironmentCloneGitRepo.go b/cmd/abapEnvironmentCloneGitRepo.go index b5913dad7e..71cfe60abd 100644 --- a/cmd/abapEnvironmentCloneGitRepo.go +++ b/cmd/abapEnvironmentCloneGitRepo.go @@ -85,12 +85,15 @@ func cloneSingleRepo(apiManager abaputils.SoftwareComponentApiManagerInterface, log.Entry().Info("Start cloning " + logString) abaputils.AddDefaultDashedLine(1) - alreadyCloned, activeBranch, errCheckCloned := api.GetRepository() + alreadyCloned, activeBranch, errCheckCloned, isByog := api.GetRepository() if errCheckCloned != nil { return errors.Wrapf(errCheckCloned, errorString) } if !alreadyCloned { + if isByog { + api.UpdateRepoWithBYOGCredentials(config.ByogAuthMethod, config.ByogUsername, config.ByogPassword) + } errClone := api.Clone() if errClone != nil { return errors.Wrapf(errClone, errorString) diff --git a/pkg/abaputils/manageGitRepositoryUtils.go b/pkg/abaputils/manageGitRepositoryUtils.go index 1d956f2afc..b0961cbd06 100644 --- a/pkg/abaputils/manageGitRepositoryUtils.go +++ b/pkg/abaputils/manageGitRepositoryUtils.go @@ -186,6 +186,7 @@ func GetRepositories(config *RepositoriesConfig, branchRequired bool) ([]Reposit return repositories, fmt.Errorf("Error in config file %v, %w", config.Repositories, err) } repositories = descriptor.Repositories + // LOOP } if config.RepositoryName != "" && config.BranchName != "" { repositories = append(repositories, Repository{Name: config.RepositoryName, Branch: config.BranchName}) @@ -193,15 +194,15 @@ func GetRepositories(config *RepositoriesConfig, branchRequired bool) ([]Reposit if config.RepositoryName != "" && !branchRequired { repositories = append(repositories, Repository{Name: config.RepositoryName, CommitID: config.CommitID}) } - if config.ByogAuthMethod != "" { - repositories[0].ByogAuthMethod = config.ByogAuthMethod - } - if config.ByogUsername != "" { - repositories[0].ByogUsername = config.ByogPassword - } - if config.ByogPassword != "" { - repositories[0].ByogPassword = config.ByogPassword - } + // if config.ByogAuthMethod != "" { + // repositories[0].ByogAuthMethod = config.ByogAuthMethod + // } + // if config.ByogUsername != "" { + // repositories[0].ByogUsername = config.ByogUsername + // } + // if config.ByogPassword != "" { + // repositories[0].ByogPassword = config.ByogPassword + // } if len(config.RepositoryNames) > 0 { for _, repository := range config.RepositoryNames { repositories = append(repositories, Repository{Name: repository}) diff --git a/pkg/abaputils/sap_com_0510.go b/pkg/abaputils/sap_com_0510.go index f543c9ff6f..24d3d99251 100644 --- a/pkg/abaputils/sap_com_0510.go +++ b/pkg/abaputils/sap_com_0510.go @@ -225,10 +225,10 @@ func (api *SAP_COM_0510) GetAction() (string, error) { return abapStatusCode, nil } -func (api *SAP_COM_0510) GetRepository() (bool, string, error) { +func (api *SAP_COM_0510) GetRepository() (bool, string, error, bool) { if api.repository.Name == "" { - return false, "", errors.New("An empty string was passed for the parameter 'repositoryName'") + return false, "", errors.New("An empty string was passed for the parameter 'repositoryName'"), false } swcConnectionDetails := api.con @@ -236,7 +236,7 @@ func (api *SAP_COM_0510) GetRepository() (bool, string, error) { resp, err := GetHTTPResponse("GET", swcConnectionDetails, nil, api.client) if err != nil { _, errRepo := HandleHTTPError(resp, err, "Reading the Repository / Software Component failed", api.con) - return false, "", errRepo + return false, "", errRepo, false } defer resp.Body.Close() @@ -244,25 +244,25 @@ func (api *SAP_COM_0510) GetRepository() (bool, string, error) { var abapResp map[string]*json.RawMessage bodyText, errRead := io.ReadAll(resp.Body) if errRead != nil { - return false, "", err + return false, "", err, false } if err := json.Unmarshal(bodyText, &abapResp); err != nil { - return false, "", err + return false, "", err, false } if err := json.Unmarshal(*abapResp["d"], &body); err != nil { - return false, "", err + return false, "", err, false } if reflect.DeepEqual(RepositoryEntity{}, body) { log.Entry().WithField("StatusCode", resp.Status).WithField("repositoryName", api.repository.Name).WithField("branchName", api.repository.Branch).WithField("commitID", api.repository.CommitID).WithField("Tag", api.repository.Tag).Error("Could not Clone the Repository / Software Component") err := errors.New("Request to ABAP System not successful") - return false, "", err + return false, "", err, false } if body.AvailOnInst { - return true, body.ActiveBranch, nil + return true, body.ActiveBranch, nil, false } - return false, "", err + return false, "", err, false } @@ -399,3 +399,8 @@ func (api *SAP_COM_0510) ConvertTime(logTimeStamp string) time.Time { t := time.Unix(n, 0).UTC() return t } + +// Dummy implementation of the "optional" method UpdateRepoWithBYOGCredentials (only used in SAP_COM_0948) +func (api *SAP_COM_0510) UpdateRepoWithBYOGCredentials(byogAuthMethod string, byogUsername string, byogPassword string) { + panic("UpdateRepoWithBYOGCredentials cannot be used in SAP_COM_0510") +} diff --git a/pkg/abaputils/sap_com_0510_test.go b/pkg/abaputils/sap_com_0510_test.go index d18421e3b9..b7172e6c62 100644 --- a/pkg/abaputils/sap_com_0510_test.go +++ b/pkg/abaputils/sap_com_0510_test.go @@ -365,7 +365,7 @@ func TestGetRepo(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0510{}, api.(*SAP_COM_0510), "API has wrong type") - cloned, activeBranch, errAction := api.GetRepository() + cloned, activeBranch, errAction, _ := api.GetRepository() assert.True(t, cloned) assert.Equal(t, "testBranch1", activeBranch) assert.NoError(t, errAction) diff --git a/pkg/abaputils/sap_com_0948.go b/pkg/abaputils/sap_com_0948.go index de1ac13eba..05db51605e 100644 --- a/pkg/abaputils/sap_com_0948.go +++ b/pkg/abaputils/sap_com_0948.go @@ -238,10 +238,10 @@ func (api *SAP_COM_0948) GetAction() (string, error) { return abapStatusCode, nil } -func (api *SAP_COM_0948) GetRepository() (bool, string, error) { +func (api *SAP_COM_0948) GetRepository() (bool, string, error, bool) { if api.repository.Name == "" { - return false, "", errors.New("An empty string was passed for the parameter 'repositoryName'") + return false, "", errors.New("An empty string was passed for the parameter 'repositoryName'"), false } swcConnectionDetails := api.con @@ -249,30 +249,41 @@ func (api *SAP_COM_0948) GetRepository() (bool, string, error) { resp, err := GetHTTPResponse("GET", swcConnectionDetails, nil, api.client) if err != nil { _, errRepo := HandleHTTPError(resp, err, "Reading the Repository / Software Component failed", api.con) - return false, "", errRepo + return false, "", errRepo, false } defer resp.Body.Close() var body RepositoryEntity bodyText, errRead := io.ReadAll(resp.Body) if errRead != nil { - return false, "", err + return false, "", err, false } if err := json.Unmarshal(bodyText, &body); err != nil { - return false, "", err + return false, "", err, false } if reflect.DeepEqual(RepositoryEntity{}, body) { log.Entry().WithField("StatusCode", resp.Status).WithField("repositoryName", api.repository.Name).WithField("branchName", api.repository.Branch).WithField("commitID", api.repository.CommitID).WithField("Tag", api.repository.Tag).Error("Could not Clone the Repository / Software Component") err := errors.New("Request to ABAP System not successful") - return false, "", err + return false, "", err, false } if body.AvailOnInst { - return true, body.ActiveBranch, nil + return true, body.ActiveBranch, nil, false } - return false, "", err + if body.ByogUrl != "" { + return false, "", err, true + } + + return false, "", err, false + +} + +func (api *SAP_COM_0948) UpdateRepoWithBYOGCredentials(byogAuthMethod string, byogUsername string, byogPassword string) { + api.repository.ByogAuthMethod = byogAuthMethod + api.repository.ByogUsername = byogUsername + api.repository.ByogPassword = byogPassword } func (api *SAP_COM_0948) Clone() error { diff --git a/pkg/abaputils/sap_com_0948_test.go b/pkg/abaputils/sap_com_0948_test.go index 69fe0a0828..b0eae899ea 100644 --- a/pkg/abaputils/sap_com_0948_test.go +++ b/pkg/abaputils/sap_com_0948_test.go @@ -402,7 +402,7 @@ func TestGetRepo0948(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0948{}, api.(*SAP_COM_0948), "API has wrong type") - cloned, activeBranch, errAction := api.GetRepository() + cloned, activeBranch, errAction, _ := api.GetRepository() assert.True(t, cloned) assert.Equal(t, "testBranch1", activeBranch) assert.NoError(t, errAction) diff --git a/pkg/abaputils/softwareComponentApiManager.go b/pkg/abaputils/softwareComponentApiManager.go index 3e3de4e2da..0bd7b712f9 100644 --- a/pkg/abaputils/softwareComponentApiManager.go +++ b/pkg/abaputils/softwareComponentApiManager.go @@ -59,7 +59,7 @@ type SoftwareComponentApiInterface interface { setSleepTimeConfig(timeUnit time.Duration, maxSleepTime time.Duration) getSleepTime(n int) (time.Duration, error) getUUID() string - GetRepository() (bool, string, error) + GetRepository() (bool, string, error, bool) Clone() error Pull() error CheckoutBranch() error @@ -69,6 +69,7 @@ type SoftwareComponentApiInterface interface { GetLogProtocol(LogResultsV2, int) (result []LogProtocol, count int, err error) ConvertTime(logTimeStamp string) time.Time GetExecutionLog() (ExecutionLog, error) + UpdateRepoWithBYOGCredentials(string, string, string) } /**************************************** @@ -128,6 +129,7 @@ type CloneEntity struct { type RepositoryEntity struct { Metadata AbapMetadata `json:"__metadata"` ScName string `json:"sc_name"` + ByogUrl string `json:"url"` ActiveBranch string `json:"active_branch"` AvailOnInst bool `json:"avail_on_inst"` } From ca3f6c10824ec9d7e28ab45d6db127b5ecbe0a18 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 14 Jun 2024 14:59:05 +0200 Subject: [PATCH 05/33] fixing typo in username --- vars/abapEnvironmentCloneGitRepo.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/abapEnvironmentCloneGitRepo.groovy b/vars/abapEnvironmentCloneGitRepo.groovy index e175316200..46aaf03120 100644 --- a/vars/abapEnvironmentCloneGitRepo.groovy +++ b/vars/abapEnvironmentCloneGitRepo.groovy @@ -6,7 +6,7 @@ import groovy.transform.Field void call(Map parameters = [:]) { List credentials = [ [type: 'usernamePassword', id: 'abapCredentialsId', env: ['PIPER_username', 'PIPER_password']], - [type: 'usernamePassword', id: 'byogCredentialsId', env: ['PIPER_boygUsername', 'PIPER_byogPassword']] + [type: 'usernamePassword', id: 'byogCredentialsId', env: ['PIPER_byogUsername', 'PIPER_byogPassword']] ] piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials, false, false, true) } From c7f4687c7bfd5fb5402c9d2526fd996160472139 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 14 Jun 2024 15:19:52 +0200 Subject: [PATCH 06/33] remove aliases in config yaml --- resources/metadata/abapEnvironmentCloneGitRepo.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/resources/metadata/abapEnvironmentCloneGitRepo.yaml b/resources/metadata/abapEnvironmentCloneGitRepo.yaml index e4f1f60c05..fc8c064c8f 100644 --- a/resources/metadata/abapEnvironmentCloneGitRepo.yaml +++ b/resources/metadata/abapEnvironmentCloneGitRepo.yaml @@ -19,11 +19,8 @@ spec: - name: cfCredentialsId - name: credentialsId - name: byogCredentialsId - description: Jenkins credentials ID containing user and password to authenticate to the for a Software Component which is used in a BYOG szenario + description: Jenkins credentials ID containing boygUsername and byogPassword to authenticate to the for a Software Component which is used in a BYOG szenario type: jenkins - aliases: - - name: cfCredentialsId - - name: credentialsId params: - name: username type: string From 65202b13631f2158f80aed0852971b858eb86ab3 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 14 Jun 2024 15:39:22 +0200 Subject: [PATCH 07/33] change yaml config --- resources/metadata/abapEnvironmentCloneGitRepo.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/metadata/abapEnvironmentCloneGitRepo.yaml b/resources/metadata/abapEnvironmentCloneGitRepo.yaml index fc8c064c8f..3770b9f358 100644 --- a/resources/metadata/abapEnvironmentCloneGitRepo.yaml +++ b/resources/metadata/abapEnvironmentCloneGitRepo.yaml @@ -48,9 +48,9 @@ spec: - name: abapCredentialsId type: secret param: password - - name: byogPassword + - name: byogUsername type: string - description: Password for bring your own git (BYOG) authentication + description: Username for bring your own git (BYOG) authentication scope: - PARAMETERS - STAGES @@ -61,10 +61,10 @@ spec: resourceRef: - name: byogCredentialsId type: secret - param: byogPassword - - name: byogUsername + param: username + - name: byogPassword type: string - description: Username for bring your own git (BYOG) authentication + description: Password for bring your own git (BYOG) authentication scope: - PARAMETERS - STAGES @@ -75,7 +75,7 @@ spec: resourceRef: - name: byogCredentialsId type: secret - param: byogUsername + param: password - name: byogAuthMethod type: string description: Specifies which authentication method is used for bring your own git (BYOG) repositories From 0cc82a116d936a3f3bfb0b17d4f865e5a2208796 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 14 Jun 2024 16:20:21 +0200 Subject: [PATCH 08/33] logs --- cmd/abapEnvironmentCloneGitRepo.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/abapEnvironmentCloneGitRepo.go b/cmd/abapEnvironmentCloneGitRepo.go index 71cfe60abd..99763dbcf4 100644 --- a/cmd/abapEnvironmentCloneGitRepo.go +++ b/cmd/abapEnvironmentCloneGitRepo.go @@ -1,6 +1,7 @@ package cmd import ( + "os" "time" "github.com/SAP/jenkins-library/pkg/abaputils" @@ -90,8 +91,15 @@ func cloneSingleRepo(apiManager abaputils.SoftwareComponentApiManagerInterface, return errors.Wrapf(errCheckCloned, errorString) } + log.Entry().Infof("Value of isByog: %t", isByog) + + log.Entry().Infof("Envs:") + log.Entry().Infof(os.Getenv("PIPER_byogPassword")) + log.Entry().Infof(os.Getenv("PIPER_byogUsername")) + if !alreadyCloned { if isByog { + log.Entry().Infof("Is byog Repo") api.UpdateRepoWithBYOGCredentials(config.ByogAuthMethod, config.ByogUsername, config.ByogPassword) } errClone := api.Clone() From de1c00f8856d37bc6dae3be3481c4ac0ffe85ae1 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 14 Jun 2024 16:28:14 +0200 Subject: [PATCH 09/33] change info log --- cmd/abapEnvironmentCloneGitRepo.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/abapEnvironmentCloneGitRepo.go b/cmd/abapEnvironmentCloneGitRepo.go index 99763dbcf4..69f7f2c6a7 100644 --- a/cmd/abapEnvironmentCloneGitRepo.go +++ b/cmd/abapEnvironmentCloneGitRepo.go @@ -91,15 +91,15 @@ func cloneSingleRepo(apiManager abaputils.SoftwareComponentApiManagerInterface, return errors.Wrapf(errCheckCloned, errorString) } - log.Entry().Infof("Value of isByog: %t", isByog) + log.Entry().Info("Value of isByog: %t", isByog) - log.Entry().Infof("Envs:") - log.Entry().Infof(os.Getenv("PIPER_byogPassword")) - log.Entry().Infof(os.Getenv("PIPER_byogUsername")) + log.Entry().Info("Envs:") + log.Entry().Info(os.Getenv("PIPER_byogPassword")) + log.Entry().Info(os.Getenv("PIPER_byogUsername")) if !alreadyCloned { if isByog { - log.Entry().Infof("Is byog Repo") + log.Entry().Info("Is byog Repo") api.UpdateRepoWithBYOGCredentials(config.ByogAuthMethod, config.ByogUsername, config.ByogPassword) } errClone := api.Clone() From fa5db99b1fd7a77653d22529a0edda04b8170340 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 14 Jun 2024 16:37:35 +0200 Subject: [PATCH 10/33] change logs --- cmd/abapEnvironmentCloneGitRepo.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cmd/abapEnvironmentCloneGitRepo.go b/cmd/abapEnvironmentCloneGitRepo.go index 69f7f2c6a7..afeb1aba1e 100644 --- a/cmd/abapEnvironmentCloneGitRepo.go +++ b/cmd/abapEnvironmentCloneGitRepo.go @@ -38,6 +38,10 @@ func runAbapEnvironmentCloneGitRepo(config *abapEnvironmentCloneGitRepoOptions, // Mapping for options subOptions := convertCloneConfig(config) + log.Entry().Info("Envs:") + log.Entry().Info(os.Getenv("PIPER_byogPassword")) + log.Entry().Info(os.Getenv("PIPER_byogUsername")) + errConfig := checkConfiguration(config) if errConfig != nil { return errors.Wrap(errConfig, "The provided configuration is not allowed") @@ -91,15 +95,8 @@ func cloneSingleRepo(apiManager abaputils.SoftwareComponentApiManagerInterface, return errors.Wrapf(errCheckCloned, errorString) } - log.Entry().Info("Value of isByog: %t", isByog) - - log.Entry().Info("Envs:") - log.Entry().Info(os.Getenv("PIPER_byogPassword")) - log.Entry().Info(os.Getenv("PIPER_byogUsername")) - if !alreadyCloned { if isByog { - log.Entry().Info("Is byog Repo") api.UpdateRepoWithBYOGCredentials(config.ByogAuthMethod, config.ByogUsername, config.ByogPassword) } errClone := api.Clone() From c11ba6424b8e3d95339183ec6392ee33a052e811 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 14 Jun 2024 16:44:06 +0200 Subject: [PATCH 11/33] remove logs --- cmd/abapEnvironmentCloneGitRepo.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cmd/abapEnvironmentCloneGitRepo.go b/cmd/abapEnvironmentCloneGitRepo.go index afeb1aba1e..71cfe60abd 100644 --- a/cmd/abapEnvironmentCloneGitRepo.go +++ b/cmd/abapEnvironmentCloneGitRepo.go @@ -1,7 +1,6 @@ package cmd import ( - "os" "time" "github.com/SAP/jenkins-library/pkg/abaputils" @@ -38,10 +37,6 @@ func runAbapEnvironmentCloneGitRepo(config *abapEnvironmentCloneGitRepoOptions, // Mapping for options subOptions := convertCloneConfig(config) - log.Entry().Info("Envs:") - log.Entry().Info(os.Getenv("PIPER_byogPassword")) - log.Entry().Info(os.Getenv("PIPER_byogUsername")) - errConfig := checkConfiguration(config) if errConfig != nil { return errors.Wrap(errConfig, "The provided configuration is not allowed") From fe853b9f03d0fd9c587db8f1c10d52aba60ba23d Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Wed, 19 Jun 2024 11:48:41 +0200 Subject: [PATCH 12/33] adding log statements --- cmd/abapEnvironmentCloneGitRepo.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/abapEnvironmentCloneGitRepo.go b/cmd/abapEnvironmentCloneGitRepo.go index 71cfe60abd..0c48b66685 100644 --- a/cmd/abapEnvironmentCloneGitRepo.go +++ b/cmd/abapEnvironmentCloneGitRepo.go @@ -1,6 +1,7 @@ package cmd import ( + "os" "time" "github.com/SAP/jenkins-library/pkg/abaputils" @@ -22,6 +23,8 @@ func abapEnvironmentCloneGitRepo(config abapEnvironmentCloneGitRepoOptions, _ *t Exec: &c, } + log.Entry().Infof("Test log Statement") + apiManager := abaputils.SoftwareComponentApiManager{ Client: &piperhttp.Client{}, PollIntervall: 5 * time.Second, @@ -37,6 +40,10 @@ func runAbapEnvironmentCloneGitRepo(config *abapEnvironmentCloneGitRepoOptions, // Mapping for options subOptions := convertCloneConfig(config) + log.Entry().Info("Envs:") + log.Entry().Info(os.Getenv("PIPER_byogPassword")) + log.Entry().Info(os.Getenv("PIPER_byogUsername")) + errConfig := checkConfiguration(config) if errConfig != nil { return errors.Wrap(errConfig, "The provided configuration is not allowed") From d2f88d935d1ba92b474b592884022348c5095c85 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Wed, 19 Jun 2024 15:11:33 +0200 Subject: [PATCH 13/33] remove log statements --- cmd/abapEnvironmentCloneGitRepo.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cmd/abapEnvironmentCloneGitRepo.go b/cmd/abapEnvironmentCloneGitRepo.go index 0c48b66685..71cfe60abd 100644 --- a/cmd/abapEnvironmentCloneGitRepo.go +++ b/cmd/abapEnvironmentCloneGitRepo.go @@ -1,7 +1,6 @@ package cmd import ( - "os" "time" "github.com/SAP/jenkins-library/pkg/abaputils" @@ -23,8 +22,6 @@ func abapEnvironmentCloneGitRepo(config abapEnvironmentCloneGitRepoOptions, _ *t Exec: &c, } - log.Entry().Infof("Test log Statement") - apiManager := abaputils.SoftwareComponentApiManager{ Client: &piperhttp.Client{}, PollIntervall: 5 * time.Second, @@ -40,10 +37,6 @@ func runAbapEnvironmentCloneGitRepo(config *abapEnvironmentCloneGitRepoOptions, // Mapping for options subOptions := convertCloneConfig(config) - log.Entry().Info("Envs:") - log.Entry().Info(os.Getenv("PIPER_byogPassword")) - log.Entry().Info(os.Getenv("PIPER_byogUsername")) - errConfig := checkConfiguration(config) if errConfig != nil { return errors.Wrap(errConfig, "The provided configuration is not allowed") From 9adcf26544dfce1166584a455584175e2d46ad43 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Wed, 19 Jun 2024 15:35:50 +0200 Subject: [PATCH 14/33] fixing typo in test class --- pkg/abaputils/sap_com_0948_test.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/abaputils/sap_com_0948_test.go b/pkg/abaputils/sap_com_0948_test.go index b0eae899ea..79e97a9b85 100644 --- a/pkg/abaputils/sap_com_0948_test.go +++ b/pkg/abaputils/sap_com_0948_test.go @@ -49,7 +49,7 @@ func TestRetry0948(t *testing.T) { errAction := api.(*SAP_COM_0948).triggerRequest(ConnectionDetailsHTTP{User: "CC_USER", Password: "abc123", URL: "https://example.com/path"}, []byte("{}")) assert.NoError(t, errAction) - assert.Equal(t, "GUID", api.getUUID(), "API does not cotain correct UUID") + assert.Equal(t, "GUID", api.getUUID(), "API does not contain correct UUID") }) @@ -79,7 +79,7 @@ func TestRetry0948(t *testing.T) { errAction := api.(*SAP_COM_0948).triggerRequest(ConnectionDetailsHTTP{User: "CC_USER", Password: "abc123", URL: "https://example.com/path"}, []byte("{}")) assert.ErrorContains(t, errAction, "HTTP 400: A4C_A2G/224 - Error Text") - assert.Empty(t, api.getUUID(), "API does not cotain correct UUID") + assert.Empty(t, api.getUUID(), "API does not contain correct UUID") }) @@ -125,7 +125,7 @@ func TestRetry0948(t *testing.T) { errAction := api.(*SAP_COM_0948).triggerRequest(ConnectionDetailsHTTP{User: "CC_USER", Password: "abc123", URL: "https://example.com/path"}, []byte("{}")) assert.ErrorContains(t, errAction, "HTTP 400: A4C_A2G/228 - Error Text") - assert.Empty(t, api.getUUID(), "API does not cotain correct UUID") + assert.Empty(t, api.getUUID(), "API does not contain correct UUID") assert.Equal(t, 6, len(client.BodyList), "Expected maxSleepTime to limit requests") }) @@ -172,7 +172,7 @@ func TestRetry0948(t *testing.T) { errAction := api.(*SAP_COM_0948).triggerRequest(ConnectionDetailsHTTP{User: "CC_USER", Password: "abc123", URL: "https://example.com/path"}, []byte("{}")) assert.ErrorContains(t, errAction, "HTTP 400: A4C_A2G/228 - Error Text") - assert.Empty(t, api.getUUID(), "API does not cotain correct UUID") + assert.Empty(t, api.getUUID(), "API does not contain correct UUID") assert.Equal(t, 5, len(client.BodyList), "Expected maxRetries to limit requests") }) @@ -198,7 +198,7 @@ func TestClone0948(t *testing.T) { errClone := api.Clone() assert.NoError(t, errClone) - assert.Equal(t, "GUID", api.getUUID(), "API does not cotain correct UUID") + assert.Equal(t, "GUID", api.getUUID(), "API does not contain correct UUID") }) t.Run("Test Clone Failure", func(t *testing.T) { @@ -222,7 +222,7 @@ func TestClone0948(t *testing.T) { errClone := api.Clone() assert.ErrorContains(t, errClone, "Request to ABAP System not successful") - assert.Empty(t, api.getUUID(), "API does not cotain correct UUID") + assert.Empty(t, api.getUUID(), "API does not contain correct UUID") }) t.Run("Test Clone Retry", func(t *testing.T) { @@ -251,7 +251,7 @@ func TestClone0948(t *testing.T) { errClone := api.Clone() assert.NoError(t, errClone) - assert.Equal(t, "GUID", api.getUUID(), "API does not cotain correct UUID") + assert.Equal(t, "GUID", api.getUUID(), "API does not contain correct UUID") }) t.Run("Test Clone Body Success", func(t *testing.T) { @@ -312,7 +312,7 @@ func TestPull0948(t *testing.T) { errPull := api.Pull() assert.NoError(t, errPull) - assert.Equal(t, "GUID", api.getUUID(), "API does not cotain correct UUID") + assert.Equal(t, "GUID", api.getUUID(), "API does not contain correct UUID") }) t.Run("Test Pull Failure", func(t *testing.T) { @@ -334,7 +334,7 @@ func TestPull0948(t *testing.T) { errPull := api.Pull() assert.ErrorContains(t, errPull, "Request to ABAP System not successful") - assert.Empty(t, api.getUUID(), "API does not cotain correct UUID") + assert.Empty(t, api.getUUID(), "API does not contain correct UUID") }) } @@ -358,7 +358,7 @@ func TestCheckout0948(t *testing.T) { errCheckout := api.CheckoutBranch() assert.NoError(t, errCheckout) - assert.Equal(t, "GUID", api.getUUID(), "API does not cotain correct UUID") + assert.Equal(t, "GUID", api.getUUID(), "API does not contain correct UUID") }) t.Run("Test Checkout Failure", func(t *testing.T) { @@ -380,7 +380,7 @@ func TestCheckout0948(t *testing.T) { errCheckoput := api.CheckoutBranch() assert.ErrorContains(t, errCheckoput, "Request to ABAP System not successful") - assert.Empty(t, api.getUUID(), "API does not cotain correct UUID") + assert.Empty(t, api.getUUID(), "API does not contain correct UUID") }) } @@ -429,7 +429,7 @@ func TestCreateTag0948(t *testing.T) { errCreateTag := api.CreateTag(Tag{TagName: "myTag", TagDescription: "descr"}) assert.NoError(t, errCreateTag) - assert.Equal(t, "GUID", api.getUUID(), "API does not cotain correct UUID") + assert.Equal(t, "GUID", api.getUUID(), "API does not contain correct UUID") }) t.Run("Test Tag Failure", func(t *testing.T) { @@ -451,7 +451,7 @@ func TestCreateTag0948(t *testing.T) { errCreateTag := api.CreateTag(Tag{TagName: "myTag", TagDescription: "descr"}) assert.ErrorContains(t, errCreateTag, "Request to ABAP System not successful") - assert.Empty(t, api.getUUID(), "API does not cotain correct UUID") + assert.Empty(t, api.getUUID(), "API does not contain correct UUID") }) t.Run("Test Tag Empty", func(t *testing.T) { @@ -473,7 +473,7 @@ func TestCreateTag0948(t *testing.T) { errCreateTag := api.CreateTag(Tag{}) assert.ErrorContains(t, errCreateTag, "No Tag provided") - assert.Empty(t, api.getUUID(), "API does not cotain correct UUID") + assert.Empty(t, api.getUUID(), "API does not contain correct UUID") }) } From 5275375efcd3c4b6821b40a88101f043f1737a14 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Wed, 19 Jun 2024 15:54:39 +0200 Subject: [PATCH 15/33] change repoTest structure --- pkg/abaputils/sap_com_0948_test.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/abaputils/sap_com_0948_test.go b/pkg/abaputils/sap_com_0948_test.go index 79e97a9b85..3b884911bd 100644 --- a/pkg/abaputils/sap_com_0948_test.go +++ b/pkg/abaputils/sap_com_0948_test.go @@ -20,6 +20,10 @@ func init() { repoTest0948.Name = "/DMO/REPO" repoTest0948.Branch = "main" + repoTest0948.ByogAuthMethod = "token" + repoTest0948.ByogUsername = "byogUser" + repoTest0948.ByogPassword = "byogToken" + } func TestRetry0948(t *testing.T) { @@ -257,7 +261,7 @@ func TestClone0948(t *testing.T) { t.Run("Test Clone Body Success", func(t *testing.T) { cloneBody := []byte(repoTest0948.GetCloneRequestBody()) - assert.Equal(t, "{\"branch_name\":\"main\"}", string(cloneBody), "Clone body is not correct") + assert.Equal(t, "{\"branch_name\":\"main\", \"auth_method\":\"token\", \"username\":\"byogUser\", \"password\":\"byogToken\"}", string(cloneBody), "Clone body is not correct") }) t.Run("Test Clone Body Failure", func(t *testing.T) { @@ -268,26 +272,24 @@ func TestClone0948(t *testing.T) { assert.NotEqual(t, "{\"branch_name\":\"main\"}", string(cloneBody), "Clone body should not match") repoTest0948.Branch = "main" + }) t.Run("Test Clone Body BYOG Success", func(t *testing.T) { - repoTest0948.ByogAuthMethod = "token" - repoTest0948.ByogUsername = "byogUser" - repoTest0948.ByogPassword = "byogToken" - cloneBody := []byte(repoTest0948.GetCloneRequestBody()) assert.Equal(t, "{\"branch_name\":\"main\", \"auth_method\":\"token\", \"username\":\"byogUser\", \"password\":\"byogToken\"}", string(cloneBody), "Clone body for byog parameter is not correct") + }) t.Run("Test Clone Body BYOG Failure", func(t *testing.T) { - repoTest0948.ByogAuthMethod = "token" - repoTest0948.ByogUsername = "byogUser" repoTest0948.ByogPassword = "wrongToken" cloneBody := []byte(repoTest0948.GetCloneRequestBody()) assert.NotEqual(t, "{\"branch_name\":\"main\", \"auth_method\":\"token\", \"username\":\"byogUser\", \"password\":\"byogToken\"}", string(cloneBody), "Clone body for byog parameter should not match") + + repoTest0948.ByogPassword = "byogToken" }) } From f77cb4bd362bcfa25cfb65fcd53ae0b53aa0625d Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Wed, 19 Jun 2024 16:01:43 +0200 Subject: [PATCH 16/33] remove comment --- pkg/abaputils/manageGitRepositoryUtils.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/pkg/abaputils/manageGitRepositoryUtils.go b/pkg/abaputils/manageGitRepositoryUtils.go index b0961cbd06..910ed1befd 100644 --- a/pkg/abaputils/manageGitRepositoryUtils.go +++ b/pkg/abaputils/manageGitRepositoryUtils.go @@ -194,15 +194,7 @@ func GetRepositories(config *RepositoriesConfig, branchRequired bool) ([]Reposit if config.RepositoryName != "" && !branchRequired { repositories = append(repositories, Repository{Name: config.RepositoryName, CommitID: config.CommitID}) } - // if config.ByogAuthMethod != "" { - // repositories[0].ByogAuthMethod = config.ByogAuthMethod - // } - // if config.ByogUsername != "" { - // repositories[0].ByogUsername = config.ByogUsername - // } - // if config.ByogPassword != "" { - // repositories[0].ByogPassword = config.ByogPassword - // } + if len(config.RepositoryNames) > 0 { for _, repository := range config.RepositoryNames { repositories = append(repositories, Repository{Name: repository}) From e92f5274264eaacc47f2976228579ca52b420ef0 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Wed, 19 Jun 2024 16:03:52 +0200 Subject: [PATCH 17/33] remove comment --- pkg/abaputils/manageGitRepositoryUtils.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/abaputils/manageGitRepositoryUtils.go b/pkg/abaputils/manageGitRepositoryUtils.go index 910ed1befd..63b7f01575 100644 --- a/pkg/abaputils/manageGitRepositoryUtils.go +++ b/pkg/abaputils/manageGitRepositoryUtils.go @@ -186,7 +186,6 @@ func GetRepositories(config *RepositoriesConfig, branchRequired bool) ([]Reposit return repositories, fmt.Errorf("Error in config file %v, %w", config.Repositories, err) } repositories = descriptor.Repositories - // LOOP } if config.RepositoryName != "" && config.BranchName != "" { repositories = append(repositories, Repository{Name: config.RepositoryName, Branch: config.BranchName}) From df2de60e3596abfef4bee909026b85351f9fb9c9 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Wed, 19 Jun 2024 16:28:25 +0200 Subject: [PATCH 18/33] generate --- cmd/abapEnvironmentCloneGitRepo_generated.go | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/abapEnvironmentCloneGitRepo_generated.go b/cmd/abapEnvironmentCloneGitRepo_generated.go index 0c0c050496..df97bc9181 100644 --- a/cmd/abapEnvironmentCloneGitRepo_generated.go +++ b/cmd/abapEnvironmentCloneGitRepo_generated.go @@ -18,8 +18,8 @@ import ( type abapEnvironmentCloneGitRepoOptions struct { Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` - ByogPassword string `json:"byogPassword,omitempty"` ByogUsername string `json:"byogUsername,omitempty"` + ByogPassword string `json:"byogPassword,omitempty"` ByogAuthMethod string `json:"byogAuthMethod,omitempty"` Repositories string `json:"repositories,omitempty"` RepositoryName string `json:"repositoryName,omitempty"` @@ -71,8 +71,8 @@ Please provide either of the following options: } log.RegisterSecret(stepConfig.Username) log.RegisterSecret(stepConfig.Password) - log.RegisterSecret(stepConfig.ByogPassword) log.RegisterSecret(stepConfig.ByogUsername) + log.RegisterSecret(stepConfig.ByogPassword) if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 { sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID) @@ -141,11 +141,11 @@ Please provide either of the following options: } func addAbapEnvironmentCloneGitRepoFlags(cmd *cobra.Command, stepConfig *abapEnvironmentCloneGitRepoOptions) { - cmd.Flags().StringVar(&stepConfig.ByogPassword, "byogPassword", os.Getenv("PIPER_byogPassword"), "Password for bring your own git (BYOG) authentication") - cmd.Flags().StringVar(&stepConfig.ByogUsername, "byogUsername", os.Getenv("PIPER_byogUsername"), "Username for bring your own git (BYOG) authentication") - cmd.Flags().StringVar(&stepConfig.ByogAuthMethod, "byogAuthMethod", os.Getenv("PIPER_byogAuthMethod"), "Specifies which authentication method is used for bring your own git (BYOG) repositories") cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0948") cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password for either the Cloud Foundry API or the Communication Arrangement for SAP_COM_0948") + cmd.Flags().StringVar(&stepConfig.ByogUsername, "byogUsername", os.Getenv("PIPER_byogUsername"), "Username for bring your own git (BYOG) authentication") + cmd.Flags().StringVar(&stepConfig.ByogPassword, "byogPassword", os.Getenv("PIPER_byogPassword"), "Password for bring your own git (BYOG) authentication") + cmd.Flags().StringVar(&stepConfig.ByogAuthMethod, "byogAuthMethod", os.Getenv("PIPER_byogAuthMethod"), "Specifies which authentication method is used for bring your own git (BYOG) repositories") cmd.Flags().StringVar(&stepConfig.Repositories, "repositories", os.Getenv("PIPER_repositories"), "Specifies a YAML file containing the repositories configuration") cmd.Flags().StringVar(&stepConfig.RepositoryName, "repositoryName", os.Getenv("PIPER_repositoryName"), "Specifies a repository (Software Components) on the SAP BTP ABAP Environment system") cmd.Flags().StringVar(&stepConfig.BranchName, "branchName", os.Getenv("PIPER_branchName"), "Specifies a branch of a repository (Software Components) on the SAP BTP ABAP Environment system") @@ -159,8 +159,8 @@ func addAbapEnvironmentCloneGitRepoFlags(cmd *cobra.Command, stepConfig *abapEnv cmd.MarkFlagRequired("username") cmd.MarkFlagRequired("password") - cmd.MarkFlagRequired("byogPassword") cmd.MarkFlagRequired("byogUsername") + cmd.MarkFlagRequired("byogPassword") } // retrieve step metadata @@ -175,7 +175,7 @@ func abapEnvironmentCloneGitRepoMetadata() config.StepData { Inputs: config.StepInputs{ Secrets: []config.StepSecrets{ {Name: "abapCredentialsId", Description: "Jenkins credentials ID containing user and password to authenticate to the BTP ABAP Environment system or the Cloud Foundry API", Type: "jenkins", Aliases: []config.Alias{{Name: "cfCredentialsId", Deprecated: false}, {Name: "credentialsId", Deprecated: false}}}, - {Name: "byogCredentialsId", Description: "Jenkins credentials ID containing user and password to authenticate to the for a Software Component which is used in a BYOG szenario", Type: "jenkins", Aliases: []config.Alias{{Name: "cfCredentialsId", Deprecated: false}, {Name: "credentialsId", Deprecated: false}}}, + {Name: "byogCredentialsId", Description: "Jenkins credentials ID containing boygUsername and byogPassword to authenticate to the for a Software Component which is used in a BYOG szenario", Type: "jenkins"}, }, Parameters: []config.StepParameters{ { @@ -209,11 +209,11 @@ func abapEnvironmentCloneGitRepoMetadata() config.StepData { Default: os.Getenv("PIPER_password"), }, { - Name: "byogPassword", + Name: "byogUsername", ResourceRef: []config.ResourceReference{ { Name: "byogCredentialsId", - Param: "byogPassword", + Param: "username", Type: "secret", }, }, @@ -221,14 +221,14 @@ func abapEnvironmentCloneGitRepoMetadata() config.StepData { Type: "string", Mandatory: true, Aliases: []config.Alias{}, - Default: os.Getenv("PIPER_byogPassword"), + Default: os.Getenv("PIPER_byogUsername"), }, { - Name: "byogUsername", + Name: "byogPassword", ResourceRef: []config.ResourceReference{ { Name: "byogCredentialsId", - Param: "byogUsername", + Param: "password", Type: "secret", }, }, @@ -236,7 +236,7 @@ func abapEnvironmentCloneGitRepoMetadata() config.StepData { Type: "string", Mandatory: true, Aliases: []config.Alias{}, - Default: os.Getenv("PIPER_byogUsername"), + Default: os.Getenv("PIPER_byogPassword"), }, { Name: "byogAuthMethod", From 4f452cd581aad07d6e3bcb13ae16d8608e45856c Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Wed, 19 Jun 2024 17:08:00 +0200 Subject: [PATCH 19/33] adding unit test comments --- pkg/abaputils/abaputils_test.go | 3 +++ pkg/abaputils/sap_com_0510_test.go | 3 +++ pkg/abaputils/sap_com_0948_test.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/pkg/abaputils/abaputils_test.go b/pkg/abaputils/abaputils_test.go index 48ee9aa853..d9b0cafa2d 100644 --- a/pkg/abaputils/abaputils_test.go +++ b/pkg/abaputils/abaputils_test.go @@ -1,3 +1,6 @@ +//go:build unit +// +build unit + package abaputils import ( diff --git a/pkg/abaputils/sap_com_0510_test.go b/pkg/abaputils/sap_com_0510_test.go index b7172e6c62..1e953560c0 100644 --- a/pkg/abaputils/sap_com_0510_test.go +++ b/pkg/abaputils/sap_com_0510_test.go @@ -1,3 +1,6 @@ +//go:build unit +// +build unit + package abaputils import ( diff --git a/pkg/abaputils/sap_com_0948_test.go b/pkg/abaputils/sap_com_0948_test.go index 3b884911bd..61f7a54119 100644 --- a/pkg/abaputils/sap_com_0948_test.go +++ b/pkg/abaputils/sap_com_0948_test.go @@ -1,3 +1,6 @@ +//go:build unit +// +build unit + package abaputils import ( From 573a19b2cd32eaa502902a447843df0540bfbc96 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Thu, 20 Jun 2024 12:22:10 +0200 Subject: [PATCH 20/33] adding error handling --- pkg/abaputils/manageGitRepositoryUtils.go | 20 ++++++++++++++----- pkg/abaputils/sap_com_0948.go | 7 +++++-- .../metadata/abapEnvironmentCloneGitRepo.yaml | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/pkg/abaputils/manageGitRepositoryUtils.go b/pkg/abaputils/manageGitRepositoryUtils.go index 63b7f01575..5d6f6ca204 100644 --- a/pkg/abaputils/manageGitRepositoryUtils.go +++ b/pkg/abaputils/manageGitRepositoryUtils.go @@ -211,17 +211,23 @@ func (repo *Repository) GetRequestBodyForCommitOrTag() (requestBodyString string return requestBodyString } -func (repo *Repository) GetRequestBodyForBYOGCredentials() (byogBodyString string) { +func (repo *Repository) GetRequestBodyForBYOGCredentials() (string, error) { + var byogBodyString string + if repo.ByogAuthMethod != "" { byogBodyString += `, "auth_method":"` + repo.ByogAuthMethod + `"` } if repo.ByogUsername != "" { byogBodyString += `, "username":"` + repo.ByogUsername + `"` + } else { + return "", fmt.Errorf("Failed to get BYOG credentials: %w", errors.New("Username for BYOG is missing, please provide git username to authenticate")) } if repo.ByogPassword != "" { byogBodyString += `, "password":"` + repo.ByogPassword + `"` + } else { + return "", fmt.Errorf("Failed to get BYOG credentials: %w", errors.New("Password/Token for BYOG is missing, please provide git password or token to authenticate")) } - return byogBodyString + return byogBodyString, nil } func (repo *Repository) GetLogStringForCommitOrTag() (logString string) { @@ -242,14 +248,18 @@ func (repo *Repository) GetCloneRequestBodyWithSWC() (body string) { return body } -func (repo *Repository) GetCloneRequestBody() (body string) { +func (repo *Repository) GetCloneRequestBody() (body string, err error) { if repo.CommitID != "" && repo.Tag != "" { log.Entry().WithField("Tag", repo.Tag).WithField("Commit ID", repo.CommitID).Info("The commit ID takes precedence over the tag") } requestBodyString := repo.GetRequestBodyForCommitOrTag() - byogBodyString := repo.GetRequestBodyForBYOGCredentials() + byogBodyString, err := repo.GetRequestBodyForBYOGCredentials() + if err != nil { + return "", err + } + body = `{"branch_name":"` + repo.Branch + `"` + requestBodyString + byogBodyString + `}` - return body + return body, nil } func (repo *Repository) GetCloneLogString() (logString string) { diff --git a/pkg/abaputils/sap_com_0948.go b/pkg/abaputils/sap_com_0948.go index 05db51605e..28c1847ba9 100644 --- a/pkg/abaputils/sap_com_0948.go +++ b/pkg/abaputils/sap_com_0948.go @@ -295,9 +295,12 @@ func (api *SAP_COM_0948) Clone() error { cloneConnectionDetails := api.con cloneConnectionDetails.URL = api.con.URL + api.path + api.softwareComponentEntity + api.getRepoNameForPath() + api.cloneAction - body := []byte(api.repository.GetCloneRequestBody()) + body, err := api.repository.GetCloneRequestBody() + if err != nil { + return errors.Wrap(err, "Failed to clone repository: ") + } - return api.triggerRequest(cloneConnectionDetails, body) + return api.triggerRequest(cloneConnectionDetails, []byte(body)) } diff --git a/resources/metadata/abapEnvironmentCloneGitRepo.yaml b/resources/metadata/abapEnvironmentCloneGitRepo.yaml index 3770b9f358..746c2c3a82 100644 --- a/resources/metadata/abapEnvironmentCloneGitRepo.yaml +++ b/resources/metadata/abapEnvironmentCloneGitRepo.yaml @@ -19,7 +19,7 @@ spec: - name: cfCredentialsId - name: credentialsId - name: byogCredentialsId - description: Jenkins credentials ID containing boygUsername and byogPassword to authenticate to the for a Software Component which is used in a BYOG szenario + description: Jenkins credentials ID containing ByogUsername and ByogPassword to authenticate to a software component which is used in a BYOG scenario. (https://help.sap.com/docs/btp/sap-business-technology-platform/cloning-software-components-to-abap-environment-system-383ce2f9e2eb40f1b8ad538ddf79e656) type: jenkins params: - name: username From a90781922d3db69fa1933142d26be52b96a18e6a Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Thu, 20 Jun 2024 15:16:31 +0200 Subject: [PATCH 21/33] adding isByog check --- cmd/abapEnvironmentCloneGitRepo.go | 2 +- pkg/abaputils/manageGitRepositoryUtils.go | 11 ++++++---- pkg/abaputils/sap_com_0510.go | 2 +- pkg/abaputils/sap_com_0510_test.go | 6 +++--- pkg/abaputils/sap_com_0948.go | 6 +++--- pkg/abaputils/sap_com_0948_test.go | 22 ++++++++++---------- pkg/abaputils/softwareComponentApiManager.go | 2 +- 7 files changed, 27 insertions(+), 24 deletions(-) diff --git a/cmd/abapEnvironmentCloneGitRepo.go b/cmd/abapEnvironmentCloneGitRepo.go index 71cfe60abd..da9b6d4b3f 100644 --- a/cmd/abapEnvironmentCloneGitRepo.go +++ b/cmd/abapEnvironmentCloneGitRepo.go @@ -94,7 +94,7 @@ func cloneSingleRepo(apiManager abaputils.SoftwareComponentApiManagerInterface, if isByog { api.UpdateRepoWithBYOGCredentials(config.ByogAuthMethod, config.ByogUsername, config.ByogPassword) } - errClone := api.Clone() + errClone := api.Clone(isByog) if errClone != nil { return errors.Wrapf(errClone, errorString) } diff --git a/pkg/abaputils/manageGitRepositoryUtils.go b/pkg/abaputils/manageGitRepositoryUtils.go index 5d6f6ca204..4a97624dfc 100644 --- a/pkg/abaputils/manageGitRepositoryUtils.go +++ b/pkg/abaputils/manageGitRepositoryUtils.go @@ -248,14 +248,17 @@ func (repo *Repository) GetCloneRequestBodyWithSWC() (body string) { return body } -func (repo *Repository) GetCloneRequestBody() (body string, err error) { +func (repo *Repository) GetCloneRequestBody(isByog bool) (body string, err error) { if repo.CommitID != "" && repo.Tag != "" { log.Entry().WithField("Tag", repo.Tag).WithField("Commit ID", repo.CommitID).Info("The commit ID takes precedence over the tag") } requestBodyString := repo.GetRequestBodyForCommitOrTag() - byogBodyString, err := repo.GetRequestBodyForBYOGCredentials() - if err != nil { - return "", err + var byogBodyString = "" + if isByog { + byogBodyString, err = repo.GetRequestBodyForBYOGCredentials() + if err != nil { + return "", err + } } body = `{"branch_name":"` + repo.Branch + `"` + requestBodyString + byogBodyString + `}` diff --git a/pkg/abaputils/sap_com_0510.go b/pkg/abaputils/sap_com_0510.go index 24d3d99251..a691359b64 100644 --- a/pkg/abaputils/sap_com_0510.go +++ b/pkg/abaputils/sap_com_0510.go @@ -266,7 +266,7 @@ func (api *SAP_COM_0510) GetRepository() (bool, string, error, bool) { } -func (api *SAP_COM_0510) Clone() error { +func (api *SAP_COM_0510) Clone(isByog bool) error { // Trigger the Clone of a Repository if api.repository.Name == "" { diff --git a/pkg/abaputils/sap_com_0510_test.go b/pkg/abaputils/sap_com_0510_test.go index 1e953560c0..61fce93977 100644 --- a/pkg/abaputils/sap_com_0510_test.go +++ b/pkg/abaputils/sap_com_0510_test.go @@ -199,7 +199,7 @@ func TestClone(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0510{}, api.(*SAP_COM_0510), "API has wrong type") - errClone := api.Clone() + errClone := api.Clone(false) assert.NoError(t, errClone) assert.Equal(t, "GUID", api.getUUID(), "API does not cotain correct UUID") }) @@ -223,7 +223,7 @@ func TestClone(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0510{}, api.(*SAP_COM_0510), "API has wrong type") - errClone := api.Clone() + errClone := api.Clone(false) assert.ErrorContains(t, errClone, "Request to ABAP System not successful") assert.Empty(t, api.getUUID(), "API does not cotain correct UUID") }) @@ -252,7 +252,7 @@ func TestClone(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0510{}, api.(*SAP_COM_0510), "API has wrong type") - errClone := api.Clone() + errClone := api.Clone(false) assert.NoError(t, errClone) assert.Equal(t, "GUID", api.getUUID(), "API does not cotain correct UUID") }) diff --git a/pkg/abaputils/sap_com_0948.go b/pkg/abaputils/sap_com_0948.go index 28c1847ba9..1b44c10fb9 100644 --- a/pkg/abaputils/sap_com_0948.go +++ b/pkg/abaputils/sap_com_0948.go @@ -286,7 +286,7 @@ func (api *SAP_COM_0948) UpdateRepoWithBYOGCredentials(byogAuthMethod string, by api.repository.ByogPassword = byogPassword } -func (api *SAP_COM_0948) Clone() error { +func (api *SAP_COM_0948) Clone(isByog bool) error { // Trigger the Clone of a Repository if api.repository.Name == "" { @@ -295,9 +295,9 @@ func (api *SAP_COM_0948) Clone() error { cloneConnectionDetails := api.con cloneConnectionDetails.URL = api.con.URL + api.path + api.softwareComponentEntity + api.getRepoNameForPath() + api.cloneAction - body, err := api.repository.GetCloneRequestBody() + body, err := api.repository.GetCloneRequestBody(isByog) if err != nil { - return errors.Wrap(err, "Failed to clone repository: ") + return errors.Wrap(err, "Failed to clone repository") } return api.triggerRequest(cloneConnectionDetails, []byte(body)) diff --git a/pkg/abaputils/sap_com_0948_test.go b/pkg/abaputils/sap_com_0948_test.go index 61f7a54119..9a3c398853 100644 --- a/pkg/abaputils/sap_com_0948_test.go +++ b/pkg/abaputils/sap_com_0948_test.go @@ -203,7 +203,7 @@ func TestClone0948(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0948{}, api.(*SAP_COM_0948), "API has wrong type") - errClone := api.Clone() + errClone := api.Clone(false) assert.NoError(t, errClone) assert.Equal(t, "GUID", api.getUUID(), "API does not contain correct UUID") }) @@ -227,7 +227,7 @@ func TestClone0948(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0948{}, api.(*SAP_COM_0948), "API has wrong type") - errClone := api.Clone() + errClone := api.Clone(false) assert.ErrorContains(t, errClone, "Request to ABAP System not successful") assert.Empty(t, api.getUUID(), "API does not contain correct UUID") }) @@ -256,23 +256,23 @@ func TestClone0948(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0948{}, api.(*SAP_COM_0948), "API has wrong type") - errClone := api.Clone() + errClone := api.Clone(false) assert.NoError(t, errClone) assert.Equal(t, "GUID", api.getUUID(), "API does not contain correct UUID") }) t.Run("Test Clone Body Success", func(t *testing.T) { - cloneBody := []byte(repoTest0948.GetCloneRequestBody()) - assert.Equal(t, "{\"branch_name\":\"main\", \"auth_method\":\"token\", \"username\":\"byogUser\", \"password\":\"byogToken\"}", string(cloneBody), "Clone body is not correct") + cloneBody, _ := repoTest0948.GetCloneRequestBody(false) + assert.Equal(t, "{\"branch_name\":\"main\"}", string([]byte(cloneBody)), "Clone body is not correct") }) t.Run("Test Clone Body Failure", func(t *testing.T) { repoTest0948.Branch = "wrongBranch" - cloneBody := []byte(repoTest0948.GetCloneRequestBody()) - assert.NotEqual(t, "{\"branch_name\":\"main\"}", string(cloneBody), "Clone body should not match") + cloneBody, _ := repoTest0948.GetCloneRequestBody(false) + assert.NotEqual(t, "{\"branch_name\":\"main\"}", string([]byte(cloneBody)), "Clone body should not match") repoTest0948.Branch = "main" @@ -280,8 +280,8 @@ func TestClone0948(t *testing.T) { t.Run("Test Clone Body BYOG Success", func(t *testing.T) { - cloneBody := []byte(repoTest0948.GetCloneRequestBody()) - assert.Equal(t, "{\"branch_name\":\"main\", \"auth_method\":\"token\", \"username\":\"byogUser\", \"password\":\"byogToken\"}", string(cloneBody), "Clone body for byog parameter is not correct") + cloneBody, _ := repoTest0948.GetCloneRequestBody(true) + assert.Equal(t, "{\"branch_name\":\"main\", \"auth_method\":\"token\", \"username\":\"byogUser\", \"password\":\"byogToken\"}", string([]byte(cloneBody)), "Clone body for byog parameter is not correct") }) @@ -289,8 +289,8 @@ func TestClone0948(t *testing.T) { repoTest0948.ByogPassword = "wrongToken" - cloneBody := []byte(repoTest0948.GetCloneRequestBody()) - assert.NotEqual(t, "{\"branch_name\":\"main\", \"auth_method\":\"token\", \"username\":\"byogUser\", \"password\":\"byogToken\"}", string(cloneBody), "Clone body for byog parameter should not match") + cloneBody, _ := repoTest0948.GetCloneRequestBody(true) + assert.NotEqual(t, "{\"branch_name\":\"main\", \"auth_method\":\"token\", \"username\":\"byogUser\", \"password\":\"byogToken\"}", string([]byte(cloneBody)), "Clone body for byog parameter should not match") repoTest0948.ByogPassword = "byogToken" }) diff --git a/pkg/abaputils/softwareComponentApiManager.go b/pkg/abaputils/softwareComponentApiManager.go index 0bd7b712f9..9c3b9b79e0 100644 --- a/pkg/abaputils/softwareComponentApiManager.go +++ b/pkg/abaputils/softwareComponentApiManager.go @@ -60,7 +60,7 @@ type SoftwareComponentApiInterface interface { getSleepTime(n int) (time.Duration, error) getUUID() string GetRepository() (bool, string, error, bool) - Clone() error + Clone(isByog bool) error Pull() error CheckoutBranch() error GetAction() (string, error) From f091f0cf04ef1f917116c7d40b6b8886a5cf7c86 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Thu, 20 Jun 2024 15:28:40 +0200 Subject: [PATCH 22/33] fixing unit test --- pkg/abaputils/manageGitRepositoryUtils_test.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/abaputils/manageGitRepositoryUtils_test.go b/pkg/abaputils/manageGitRepositoryUtils_test.go index ffd96a614b..d4a75b6159 100644 --- a/pkg/abaputils/manageGitRepositoryUtils_test.go +++ b/pkg/abaputils/manageGitRepositoryUtils_test.go @@ -1,6 +1,3 @@ -//go:build unit -// +build unit - package abaputils import ( @@ -268,7 +265,7 @@ func TestCreateRequestBodies(t *testing.T) { CommitID: "1234567", Tag: "myTag", } - body := repo.GetCloneRequestBody() + body, _ := repo.GetCloneRequestBody(false) assert.Equal(t, `{"branch_name":"main", "commit_id":"1234567"}`, body, "Expected different body") }) t.Run("Clone Body Tag", func(t *testing.T) { From 2ed894605e30c45d914c714764192e1f76d1b10b Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Thu, 20 Jun 2024 15:33:52 +0200 Subject: [PATCH 23/33] generate --- cmd/abapEnvironmentCloneGitRepo_generated.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/abapEnvironmentCloneGitRepo_generated.go b/cmd/abapEnvironmentCloneGitRepo_generated.go index df97bc9181..8e160194f1 100644 --- a/cmd/abapEnvironmentCloneGitRepo_generated.go +++ b/cmd/abapEnvironmentCloneGitRepo_generated.go @@ -175,7 +175,7 @@ func abapEnvironmentCloneGitRepoMetadata() config.StepData { Inputs: config.StepInputs{ Secrets: []config.StepSecrets{ {Name: "abapCredentialsId", Description: "Jenkins credentials ID containing user and password to authenticate to the BTP ABAP Environment system or the Cloud Foundry API", Type: "jenkins", Aliases: []config.Alias{{Name: "cfCredentialsId", Deprecated: false}, {Name: "credentialsId", Deprecated: false}}}, - {Name: "byogCredentialsId", Description: "Jenkins credentials ID containing boygUsername and byogPassword to authenticate to the for a Software Component which is used in a BYOG szenario", Type: "jenkins"}, + {Name: "byogCredentialsId", Description: "Jenkins credentials ID containing ByogUsername and ByogPassword to authenticate to a software component which is used in a BYOG scenario. (https://help.sap.com/docs/btp/sap-business-technology-platform/cloning-software-components-to-abap-environment-system-383ce2f9e2eb40f1b8ad538ddf79e656)", Type: "jenkins"}, }, Parameters: []config.StepParameters{ { From 1acc31c8e18816ae366e4b2578d278558b56e51a Mon Sep 17 00:00:00 2001 From: Simon Dold <48808400+doldsimo@users.noreply.github.com> Date: Thu, 20 Jun 2024 15:53:22 +0200 Subject: [PATCH 24/33] Update manageGitRepositoryUtils_test.go --- pkg/abaputils/manageGitRepositoryUtils_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/abaputils/manageGitRepositoryUtils_test.go b/pkg/abaputils/manageGitRepositoryUtils_test.go index d4a75b6159..6078d556e5 100644 --- a/pkg/abaputils/manageGitRepositoryUtils_test.go +++ b/pkg/abaputils/manageGitRepositoryUtils_test.go @@ -1,3 +1,6 @@ +//go:build unit +// +build unit + package abaputils import ( From 2282a714b1e20ca67d6591aa7c40fc17a4252f43 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 21 Jun 2024 13:04:15 +0200 Subject: [PATCH 25/33] restructure isByog parameter --- cmd/abapEnvironmentCloneGitRepo.go | 2 +- .../docs/steps/abapEnvironmentCloneGitRepo.md | 21 +++++++++++++++++++ pkg/abaputils/descriptor.go | 1 + pkg/abaputils/manageGitRepositoryUtils.go | 4 ++-- .../manageGitRepositoryUtils_test.go | 2 +- pkg/abaputils/sap_com_0510.go | 2 +- pkg/abaputils/sap_com_0510_test.go | 6 +++--- pkg/abaputils/sap_com_0948.go | 5 +++-- pkg/abaputils/sap_com_0948_test.go | 20 +++++++++++------- pkg/abaputils/softwareComponentApiManager.go | 2 +- 10 files changed, 47 insertions(+), 18 deletions(-) diff --git a/cmd/abapEnvironmentCloneGitRepo.go b/cmd/abapEnvironmentCloneGitRepo.go index da9b6d4b3f..71cfe60abd 100644 --- a/cmd/abapEnvironmentCloneGitRepo.go +++ b/cmd/abapEnvironmentCloneGitRepo.go @@ -94,7 +94,7 @@ func cloneSingleRepo(apiManager abaputils.SoftwareComponentApiManagerInterface, if isByog { api.UpdateRepoWithBYOGCredentials(config.ByogAuthMethod, config.ByogUsername, config.ByogPassword) } - errClone := api.Clone(isByog) + errClone := api.Clone() if errClone != nil { return errors.Wrapf(errClone, errorString) } diff --git a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md index 8bdf906a74..9608e94538 100644 --- a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md +++ b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md @@ -97,3 +97,24 @@ abapEnvironmentCloneGitRepo ( cfServiceKeyName: 'cfServiceKeyName' ) ``` + +## Example: Cloning a Bring Your Own Git (BYOG) repository + +Since a BYOG repository is an external repository, you must be authenticated to clone it. +For this, the corresponding credentials must be stored in Jenkins as a username and password/token. + + Store the credentials:
+A new credential with the type username and password must be stored.
+`Jenkins Dashboard > Manage Jenkins > Credentials`
+ These credentials are used to clone the byog repository. +More information on configuring the credentials can be found [here](https://www.jenkins.io/doc/book/using/using-credentials/). + +After that, the byog repository that is to be cloned must be specified in the yaml: + +```yaml +repositories: + - name: '/DMO/REPO_BYOG' + branch: 'main' +``` + +After the pipeline has run through, the repository has been cloned. \ No newline at end of file diff --git a/pkg/abaputils/descriptor.go b/pkg/abaputils/descriptor.go index cda5c54eb9..1a044d23e4 100644 --- a/pkg/abaputils/descriptor.go +++ b/pkg/abaputils/descriptor.go @@ -45,6 +45,7 @@ type Repository struct { ByogUsername string `json:"byogUsername"` ByogPassword string `json:"byogPassword"` ByogAuthMethod string `json:"byogAuthMethod"` + IsByog bool `json:",omitempty"` VersionYAML string `json:"version,omitempty"` Version string `json:"versionAAK"` AdditionalPiecelist string `json:"additionalPiecelist,omitempty"` diff --git a/pkg/abaputils/manageGitRepositoryUtils.go b/pkg/abaputils/manageGitRepositoryUtils.go index 4a97624dfc..73da35c043 100644 --- a/pkg/abaputils/manageGitRepositoryUtils.go +++ b/pkg/abaputils/manageGitRepositoryUtils.go @@ -248,13 +248,13 @@ func (repo *Repository) GetCloneRequestBodyWithSWC() (body string) { return body } -func (repo *Repository) GetCloneRequestBody(isByog bool) (body string, err error) { +func (repo *Repository) GetCloneRequestBody() (body string, err error) { if repo.CommitID != "" && repo.Tag != "" { log.Entry().WithField("Tag", repo.Tag).WithField("Commit ID", repo.CommitID).Info("The commit ID takes precedence over the tag") } requestBodyString := repo.GetRequestBodyForCommitOrTag() var byogBodyString = "" - if isByog { + if repo.IsByog { byogBodyString, err = repo.GetRequestBodyForBYOGCredentials() if err != nil { return "", err diff --git a/pkg/abaputils/manageGitRepositoryUtils_test.go b/pkg/abaputils/manageGitRepositoryUtils_test.go index d4a75b6159..b8ea9093f0 100644 --- a/pkg/abaputils/manageGitRepositoryUtils_test.go +++ b/pkg/abaputils/manageGitRepositoryUtils_test.go @@ -265,7 +265,7 @@ func TestCreateRequestBodies(t *testing.T) { CommitID: "1234567", Tag: "myTag", } - body, _ := repo.GetCloneRequestBody(false) + body, _ := repo.GetCloneRequestBody() assert.Equal(t, `{"branch_name":"main", "commit_id":"1234567"}`, body, "Expected different body") }) t.Run("Clone Body Tag", func(t *testing.T) { diff --git a/pkg/abaputils/sap_com_0510.go b/pkg/abaputils/sap_com_0510.go index a691359b64..24d3d99251 100644 --- a/pkg/abaputils/sap_com_0510.go +++ b/pkg/abaputils/sap_com_0510.go @@ -266,7 +266,7 @@ func (api *SAP_COM_0510) GetRepository() (bool, string, error, bool) { } -func (api *SAP_COM_0510) Clone(isByog bool) error { +func (api *SAP_COM_0510) Clone() error { // Trigger the Clone of a Repository if api.repository.Name == "" { diff --git a/pkg/abaputils/sap_com_0510_test.go b/pkg/abaputils/sap_com_0510_test.go index 61fce93977..1e953560c0 100644 --- a/pkg/abaputils/sap_com_0510_test.go +++ b/pkg/abaputils/sap_com_0510_test.go @@ -199,7 +199,7 @@ func TestClone(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0510{}, api.(*SAP_COM_0510), "API has wrong type") - errClone := api.Clone(false) + errClone := api.Clone() assert.NoError(t, errClone) assert.Equal(t, "GUID", api.getUUID(), "API does not cotain correct UUID") }) @@ -223,7 +223,7 @@ func TestClone(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0510{}, api.(*SAP_COM_0510), "API has wrong type") - errClone := api.Clone(false) + errClone := api.Clone() assert.ErrorContains(t, errClone, "Request to ABAP System not successful") assert.Empty(t, api.getUUID(), "API does not cotain correct UUID") }) @@ -252,7 +252,7 @@ func TestClone(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0510{}, api.(*SAP_COM_0510), "API has wrong type") - errClone := api.Clone(false) + errClone := api.Clone() assert.NoError(t, errClone) assert.Equal(t, "GUID", api.getUUID(), "API does not cotain correct UUID") }) diff --git a/pkg/abaputils/sap_com_0948.go b/pkg/abaputils/sap_com_0948.go index 1b44c10fb9..ef25db3bb6 100644 --- a/pkg/abaputils/sap_com_0948.go +++ b/pkg/abaputils/sap_com_0948.go @@ -284,9 +284,10 @@ func (api *SAP_COM_0948) UpdateRepoWithBYOGCredentials(byogAuthMethod string, by api.repository.ByogAuthMethod = byogAuthMethod api.repository.ByogUsername = byogUsername api.repository.ByogPassword = byogPassword + api.repository.IsByog = true } -func (api *SAP_COM_0948) Clone(isByog bool) error { +func (api *SAP_COM_0948) Clone() error { // Trigger the Clone of a Repository if api.repository.Name == "" { @@ -295,7 +296,7 @@ func (api *SAP_COM_0948) Clone(isByog bool) error { cloneConnectionDetails := api.con cloneConnectionDetails.URL = api.con.URL + api.path + api.softwareComponentEntity + api.getRepoNameForPath() + api.cloneAction - body, err := api.repository.GetCloneRequestBody(isByog) + body, err := api.repository.GetCloneRequestBody() if err != nil { return errors.Wrap(err, "Failed to clone repository") } diff --git a/pkg/abaputils/sap_com_0948_test.go b/pkg/abaputils/sap_com_0948_test.go index 9a3c398853..629f23c040 100644 --- a/pkg/abaputils/sap_com_0948_test.go +++ b/pkg/abaputils/sap_com_0948_test.go @@ -23,6 +23,7 @@ func init() { repoTest0948.Name = "/DMO/REPO" repoTest0948.Branch = "main" + repoTest0948.IsByog = false repoTest0948.ByogAuthMethod = "token" repoTest0948.ByogUsername = "byogUser" repoTest0948.ByogPassword = "byogToken" @@ -203,7 +204,7 @@ func TestClone0948(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0948{}, api.(*SAP_COM_0948), "API has wrong type") - errClone := api.Clone(false) + errClone := api.Clone() assert.NoError(t, errClone) assert.Equal(t, "GUID", api.getUUID(), "API does not contain correct UUID") }) @@ -227,7 +228,7 @@ func TestClone0948(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0948{}, api.(*SAP_COM_0948), "API has wrong type") - errClone := api.Clone(false) + errClone := api.Clone() assert.ErrorContains(t, errClone, "Request to ABAP System not successful") assert.Empty(t, api.getUUID(), "API does not contain correct UUID") }) @@ -256,14 +257,14 @@ func TestClone0948(t *testing.T) { assert.NoError(t, err) assert.IsType(t, &SAP_COM_0948{}, api.(*SAP_COM_0948), "API has wrong type") - errClone := api.Clone(false) + errClone := api.Clone() assert.NoError(t, errClone) assert.Equal(t, "GUID", api.getUUID(), "API does not contain correct UUID") }) t.Run("Test Clone Body Success", func(t *testing.T) { - cloneBody, _ := repoTest0948.GetCloneRequestBody(false) + cloneBody, _ := repoTest0948.GetCloneRequestBody() assert.Equal(t, "{\"branch_name\":\"main\"}", string([]byte(cloneBody)), "Clone body is not correct") }) @@ -271,7 +272,7 @@ func TestClone0948(t *testing.T) { repoTest0948.Branch = "wrongBranch" - cloneBody, _ := repoTest0948.GetCloneRequestBody(false) + cloneBody, _ := repoTest0948.GetCloneRequestBody() assert.NotEqual(t, "{\"branch_name\":\"main\"}", string([]byte(cloneBody)), "Clone body should not match") repoTest0948.Branch = "main" @@ -280,19 +281,24 @@ func TestClone0948(t *testing.T) { t.Run("Test Clone Body BYOG Success", func(t *testing.T) { - cloneBody, _ := repoTest0948.GetCloneRequestBody(true) + repoTest0948.IsByog = true + + cloneBody, _ := repoTest0948.GetCloneRequestBody() assert.Equal(t, "{\"branch_name\":\"main\", \"auth_method\":\"token\", \"username\":\"byogUser\", \"password\":\"byogToken\"}", string([]byte(cloneBody)), "Clone body for byog parameter is not correct") + repoTest0948.IsByog = false }) t.Run("Test Clone Body BYOG Failure", func(t *testing.T) { repoTest0948.ByogPassword = "wrongToken" + repoTest0948.IsByog = true - cloneBody, _ := repoTest0948.GetCloneRequestBody(true) + cloneBody, _ := repoTest0948.GetCloneRequestBody() assert.NotEqual(t, "{\"branch_name\":\"main\", \"auth_method\":\"token\", \"username\":\"byogUser\", \"password\":\"byogToken\"}", string([]byte(cloneBody)), "Clone body for byog parameter should not match") repoTest0948.ByogPassword = "byogToken" + repoTest0948.IsByog = false }) } diff --git a/pkg/abaputils/softwareComponentApiManager.go b/pkg/abaputils/softwareComponentApiManager.go index 9c3b9b79e0..0bd7b712f9 100644 --- a/pkg/abaputils/softwareComponentApiManager.go +++ b/pkg/abaputils/softwareComponentApiManager.go @@ -60,7 +60,7 @@ type SoftwareComponentApiInterface interface { getSleepTime(n int) (time.Duration, error) getUUID() string GetRepository() (bool, string, error, bool) - Clone(isByog bool) error + Clone() error Pull() error CheckoutBranch() error GetAction() (string, error) From 4c67734b51ca519e7327181e71a3dd9b18873b13 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 21 Jun 2024 13:28:06 +0200 Subject: [PATCH 26/33] adding empty line for md linter --- documentation/docs/steps/abapEnvironmentCloneGitRepo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md index 9608e94538..f099b28d9c 100644 --- a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md +++ b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md @@ -117,4 +117,4 @@ repositories: branch: 'main' ``` -After the pipeline has run through, the repository has been cloned. \ No newline at end of file +After the pipeline has run through, the repository has been cloned. From 09c79a0e94b190f59630ab9acc9fb45f9f194cc5 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 21 Jun 2024 14:28:09 +0200 Subject: [PATCH 27/33] adding config.yaml example to docs --- .../docs/steps/abapEnvironmentCloneGitRepo.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md index f099b28d9c..70d57f91f2 100644 --- a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md +++ b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md @@ -109,7 +109,20 @@ A new credential with the type username and password must be stored.
These credentials are used to clone the byog repository. More information on configuring the credentials can be found [here](https://www.jenkins.io/doc/book/using/using-credentials/). -After that, the byog repository that is to be cloned must be specified in the yaml: +The config.yaml should look like this: + +```yaml +steps: + abapEnvironmentCloneGitRepo: + repositories: 'repos.yaml' + byogCredentialsId: 'byog' + abapCredentialsId: 'abapCredentialsId' + host: '1234-abcd-5678-efgh-ijk.abap.eu10.hana.ondemand.com' +``` + +`byogCredentialsId: 'byog'` is the reference to the defined credential in Jenkins. So take care that this matches with your setup. + +After that, the byog repository that is to be cloned must be specified in the repos.yaml: ```yaml repositories: From b4e4453fcbe8d8360137186fe62738b7928b3813 Mon Sep 17 00:00:00 2001 From: Simon Dold <48808400+doldsimo@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:44:44 +0200 Subject: [PATCH 28/33] Update documentation/docs/steps/abapEnvironmentCloneGitRepo.md Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com> --- documentation/docs/steps/abapEnvironmentCloneGitRepo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md index 70d57f91f2..bb574ff048 100644 --- a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md +++ b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md @@ -115,7 +115,7 @@ The config.yaml should look like this: steps: abapEnvironmentCloneGitRepo: repositories: 'repos.yaml' - byogCredentialsId: 'byog' + byogCredentialsId: 'byogCredentialsId' abapCredentialsId: 'abapCredentialsId' host: '1234-abcd-5678-efgh-ijk.abap.eu10.hana.ondemand.com' ``` From a95ca04ee7787a38f14949fb4f7ea1be01175a6e Mon Sep 17 00:00:00 2001 From: Simon Dold <48808400+doldsimo@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:45:08 +0200 Subject: [PATCH 29/33] Update documentation/docs/steps/abapEnvironmentCloneGitRepo.md Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com> --- documentation/docs/steps/abapEnvironmentCloneGitRepo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md index bb574ff048..3ad156d493 100644 --- a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md +++ b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md @@ -100,7 +100,7 @@ abapEnvironmentCloneGitRepo ( ## Example: Cloning a Bring Your Own Git (BYOG) repository -Since a BYOG repository is an external repository, you must be authenticated to clone it. +Since a ByoG repository is an external repository, you must be authenticated to clone it. For this, the corresponding credentials must be stored in Jenkins as a username and password/token. Store the credentials:
From 47c6cf32599ee83d535a3f9d33e320be7020068d Mon Sep 17 00:00:00 2001 From: Simon Dold <48808400+doldsimo@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:45:18 +0200 Subject: [PATCH 30/33] Update documentation/docs/steps/abapEnvironmentCloneGitRepo.md Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com> --- documentation/docs/steps/abapEnvironmentCloneGitRepo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md index 3ad156d493..8ef8247018 100644 --- a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md +++ b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md @@ -106,7 +106,7 @@ For this, the corresponding credentials must be stored in Jenkins as a username Store the credentials:
A new credential with the type username and password must be stored.
`Jenkins Dashboard > Manage Jenkins > Credentials`
- These credentials are used to clone the byog repository. + These credentials are used to clone the ByoG repository. More information on configuring the credentials can be found [here](https://www.jenkins.io/doc/book/using/using-credentials/). The config.yaml should look like this: From 297c8d5eb025fe0fba950e1f9e3c6cea5404cea5 Mon Sep 17 00:00:00 2001 From: Simon Dold <48808400+doldsimo@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:45:26 +0200 Subject: [PATCH 31/33] Update documentation/docs/steps/abapEnvironmentCloneGitRepo.md Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com> --- documentation/docs/steps/abapEnvironmentCloneGitRepo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md index 8ef8247018..f79c0ce0ed 100644 --- a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md +++ b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md @@ -120,7 +120,7 @@ steps: host: '1234-abcd-5678-efgh-ijk.abap.eu10.hana.ondemand.com' ``` -`byogCredentialsId: 'byog'` is the reference to the defined credential in Jenkins. So take care that this matches with your setup. +`byogCredentialsId: 'byogCredentialsId'` is the reference to the defined credential in Jenkins. So take care that this matches with your setup. After that, the byog repository that is to be cloned must be specified in the repos.yaml: From f7b37255eda10395fc7383453bf37fc9b5b2f832 Mon Sep 17 00:00:00 2001 From: Simon Dold <48808400+doldsimo@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:45:34 +0200 Subject: [PATCH 32/33] Update documentation/docs/steps/abapEnvironmentCloneGitRepo.md Co-authored-by: Daniel Mieg <56156797+DanielMieg@users.noreply.github.com> --- documentation/docs/steps/abapEnvironmentCloneGitRepo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md index f79c0ce0ed..6b77ca0768 100644 --- a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md +++ b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md @@ -122,7 +122,7 @@ steps: `byogCredentialsId: 'byogCredentialsId'` is the reference to the defined credential in Jenkins. So take care that this matches with your setup. -After that, the byog repository that is to be cloned must be specified in the repos.yaml: +After that, the ByoG repository that is to be cloned must be specified in the repos.yaml: ```yaml repositories: From 567294fa7c07a120fe0636b2cd11bc7778fd0245 Mon Sep 17 00:00:00 2001 From: Simon Dold Date: Fri, 21 Jun 2024 17:11:36 +0200 Subject: [PATCH 33/33] adding release --- documentation/docs/steps/abapEnvironmentCloneGitRepo.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md index 6b77ca0768..53c88aec7c 100644 --- a/documentation/docs/steps/abapEnvironmentCloneGitRepo.md +++ b/documentation/docs/steps/abapEnvironmentCloneGitRepo.md @@ -100,13 +100,15 @@ abapEnvironmentCloneGitRepo ( ## Example: Cloning a Bring Your Own Git (BYOG) repository +> Feature will be available in November 2024. + Since a ByoG repository is an external repository, you must be authenticated to clone it. For this, the corresponding credentials must be stored in Jenkins as a username and password/token. Store the credentials:
A new credential with the type username and password must be stored.
`Jenkins Dashboard > Manage Jenkins > Credentials`
- These credentials are used to clone the ByoG repository. +These credentials are used to clone the ByoG repository. More information on configuring the credentials can be found [here](https://www.jenkins.io/doc/book/using/using-credentials/). The config.yaml should look like this: