diff --git a/server/hook.go b/server/hook.go index 4feb7a3b5..2bcdc324b 100644 --- a/server/hook.go +++ b/server/hook.go @@ -207,7 +207,7 @@ func PostHook(c *gin.Context) { // persist the build config for historical correctness, restarts, etc for _, remoteYamlConfig := range remoteYamlConfigs { - _, err := findOrPersistPipelineConfig(build, remoteYamlConfig) + _, err := findOrPersistPipelineConfig(repo, build, remoteYamlConfig) if err != nil { logrus.Errorf("failure to find or persist build config for %s. %s", repo.FullName, err) c.AbortWithError(500, err) @@ -329,7 +329,7 @@ func zeroSteps(build *model.Build, remoteYamlConfigs []*remote.FileMeta) bool { return false } -func findOrPersistPipelineConfig(build *model.Build, remoteYamlConfig *remote.FileMeta) (*model.Config, error) { +func findOrPersistPipelineConfig(repo *model.Repo, build *model.Build, remoteYamlConfig *remote.FileMeta) (*model.Config, error) { sha := shasum(remoteYamlConfig.Data) conf, err := Config.Storage.Config.ConfigFindIdentical(build.RepoID, sha) if err != nil { @@ -337,7 +337,7 @@ func findOrPersistPipelineConfig(build *model.Build, remoteYamlConfig *remote.Fi RepoID: build.RepoID, Data: string(remoteYamlConfig.Data), Hash: sha, - Name: sanitizePath(remoteYamlConfig.Name), + Name: sanitizePath(remoteYamlConfig.Name, repo.Config), } err = Config.Storage.Config.ConfigCreate(conf) if err != nil { diff --git a/server/procBuilder.go b/server/procBuilder.go index f680604cd..49dcb6e2c 100644 --- a/server/procBuilder.go +++ b/server/procBuilder.go @@ -78,7 +78,7 @@ func (b *procBuilder) Build() ([]*buildItem, error) { PGID: pidSequence, State: model.StatusPending, Environ: axis, - Name: sanitizePath(y.Name), + Name: sanitizePath(y.Name, b.Repo.Config), } metadata := metadataFromStruct(b.Repo, b.Curr, b.Last, proc, b.Link) @@ -358,9 +358,9 @@ func metadataFromStruct(repo *model.Repo, build, last *model.Build, proc *model. } } -func sanitizePath(path string) string { +func sanitizePath(path string, configFolder string) string { path = strings.TrimSuffix(path, ".yml") - path = strings.TrimPrefix(path, ".drone/") + path = strings.TrimPrefix(path, configFolder) path = strings.TrimPrefix(path, ".") return path }