Skip to content

Commit

Permalink
fix: discover the git URL from the current dir
Browse files Browse the repository at this point in the history
if there is no env var to define the git URL
  • Loading branch information
jstrachan committed Mar 30, 2021
1 parent 3056276 commit e3a01e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion pkg/cmd/effective/effective.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,20 @@ func (o *Options) addPipelineParameterDefaults(path string, name string, pipelin

dscm := &o.DiscoverScm
if dscm.Dir == "" {
dscm.Dir = filepath.Dir(path)
dscm.Dir = o.Dir
if dscm.Dir == "" {
dscm.Dir = filepath.Dir(path)
}
}

// lets look for jenkins env vars
if dscm.SourceURL == "" {
dscm.SourceURL = os.Getenv("GIT_URL")
log.Logger().Infof("GIT_URL = %s", dscm.SourceURL)

if dscm.SourceURL == "" {
dscm.DiscoverFromGit = true
}
}
log.Logger().Infof("SourceURL = %s", dscm.SourceURL)

Expand Down
2 changes: 1 addition & 1 deletion pkg/lighthouses/resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type ResolverOptions struct {
func (o *ResolverOptions) AddFlags(cmd *cobra.Command) {
o.Factory.AddFlags(cmd)

cmd.Flags().StringVarP(&o.Dir, "dir", "d", ".", "The directory to look for the .lighthouse folder")
cmd.Flags().StringVarP(&o.Dir, "dir", "d", ".", "The directory to look for the .lighthouse and/or .git folders")
cmd.Flags().StringVarP(&o.CatalogOwner, "catalog-owner", "", "jenkins-x", "The github owner for the default catalog")
cmd.Flags().StringVarP(&o.CatalogRepository, "catalog-repo", "", "jx3-pipeline-catalog", "The github repository name for the default catalog")
}
Expand Down

0 comments on commit e3a01e3

Please sign in to comment.