diff --git a/pkg/bean/app.go b/pkg/bean/app.go index 57b446c270..79884460dc 100644 --- a/pkg/bean/app.go +++ b/pkg/bean/app.go @@ -29,6 +29,7 @@ import ( bean3 "github.com/devtron-labs/devtron/pkg/deployment/trigger/devtronApps/bean" "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/repository" + "strings" "time" ) @@ -81,6 +82,13 @@ type GitMaterial struct { FilterPattern []string `json:"filterPattern"` } +// UpdateSanitisedGitRepoUrl will remove all trailing slashes from git repository url +func (m *GitMaterial) UpdateSanitisedGitRepoUrl() { + for strings.HasSuffix(m.Url, "/") { + m.Url = strings.TrimSuffix(m.Url, "/") + } +} + type CiMaterial struct { Source *SourceTypeConfig `json:"source,omitempty" validate:"dive,required"` //branch for ci Path string `json:"path,omitempty"` // defaults to root of git repo diff --git a/pkg/pipeline/CiCdPipelineOrchestrator.go b/pkg/pipeline/CiCdPipelineOrchestrator.go index f4dac01608..964fd688d4 100644 --- a/pkg/pipeline/CiCdPipelineOrchestrator.go +++ b/pkg/pipeline/CiCdPipelineOrchestrator.go @@ -1291,6 +1291,7 @@ func (impl CiCdPipelineOrchestratorImpl) CreateMaterials(createMaterialRequest * } var materials []*bean.GitMaterial for _, inputMaterial := range createMaterialRequest.Material { + inputMaterial.UpdateSanitisedGitRepoUrl() m, err := impl.createMaterial(inputMaterial, createMaterialRequest.AppId, createMaterialRequest.UserId) inputMaterial.Id = m.Id if err != nil { @@ -1481,6 +1482,7 @@ func (impl CiCdPipelineOrchestratorImpl) updateMaterial(updateMaterialDTO *bean. impl.logger.Errorw("validation err", "err", err) return nil, validationErr } + updateMaterialDTO.Material.UpdateSanitisedGitRepoUrl() currentMaterial.Url = updateMaterialDTO.Material.Url basePath := path.Base(updateMaterialDTO.Material.Url) basePath = strings.TrimSuffix(basePath, ".git")