Skip to content

Commit

Permalink
feat: improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
BrendanGalloway committed Mar 17, 2022
1 parent aee37ad commit 0a98930
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cmd/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,27 @@ var Trigger = &cobra.Command{
for i := range cfg.Projects {
project := &cfg.Projects[i]
foundBranch := false
errName := project.Name
if errName == "" {
errName = string(project.ID)
}
for _, lookup := range searchBranches {
err = project.SetBranch(lookup)
if err != nil {
if !strings.Contains(err.Error(), "{message: 404 Branch Not Found}") {
log.Fatalf("unexpected error looking up branch: %s", err.Error())
log.Fatalf("unexpected error looking up branch in porject %s: %s", errName, err.Error())
}
} else {
foundBranch = true
break
}
}
if !foundBranch {
log.Fatalf("Could not find deployable branch")
log.Fatalf("Could not find deployable branch in project %s", errName)
}
err = project.TriggerPipeline(cfg.Variables)
if err != nil {
log.Fatalf("could not trigger pipeline: %v", err)
log.Fatalf("could not trigger pipeline in project %s: %v", errName, err)
}

}
Expand Down Expand Up @@ -86,9 +90,13 @@ var Trigger = &cobra.Command{
if project == nil {
log.Fatalf("HOW??")
}
errName := project.Name
if errName == "" {
errName = string(project.ID)
}
status, err := project.GetPipeLineStatus()
if err != nil {
log.Printf("Error retrieving pipeline state: %v", err)
log.Printf("Error retrieving pipeline state for project %s: %v", errName, err)
continue
}
count[status]++
Expand Down

0 comments on commit 0a98930

Please sign in to comment.