Skip to content

Commit

Permalink
Add direct link to teamcity when a build failed
Browse files Browse the repository at this point in the history
  • Loading branch information
astaluego committed Nov 26, 2019
1 parent 10b0546 commit 8dca4a3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/last_successful_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var buildsCmd = &cobra.Command{
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
fmt.Printf("builds-success [env] [branch]\n")
fmt.Printf("Usage: builds-success [env] [branch]\n")
return
}
env := args[0]
Expand Down
2 changes: 1 addition & 1 deletion cmd/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,6 @@ var pkgCmd = &cobra.Command{
return
}

buildStatus(c, buildID)
buildStatus(c, buildTypeID, buildID)
},
}
2 changes: 1 addition & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ var runCmd = &cobra.Command{
return
}

buildStatus(c, buildID)
buildStatus(c, buildTypeID, buildID)
},
}
9 changes: 7 additions & 2 deletions cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"os"
"os/signal"
"strconv"
"time"

"syscall"
Expand Down Expand Up @@ -41,11 +42,11 @@ var statusCmd = &cobra.Command{
if err != nil {
log.Fatal(err)
}
buildStatus(c, build.ID)
buildStatus(c, buildTypeID, build.ID)
},
}

func buildStatus(c tc.Config, buildID int) {
func buildStatus(c tc.Config, buildTypeID string, buildID int) {
bar := pb.StartNew(100)
var build tc.DetailedBuild
signalChan := make(chan os.Signal, 1)
Expand Down Expand Up @@ -83,6 +84,10 @@ L:
if build.Status != tc.BuildStatusSuccess {
color.Magenta("%+v", build)
color.Red("Build failed!")

// Print URL of teamcity
fmt.Printf("\nURL: %s\n", color.New(color.FgBlue).SprintFunc()(c.URL+"/viewLog.html?tab=buildLog&buildTypeId="+buildTypeID+"&buildId="+strconv.Itoa(buildID)))

return
}
color.Green("Build succeeded!")
Expand Down

0 comments on commit 8dca4a3

Please sign in to comment.