Defer updateGitHubStatus so that it reports errors that occur before the build begins
This commit is contained in:
parent
cf9b791071
commit
1e75162bc8
1 changed files with 10 additions and 6 deletions
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/drone/drone/pkg/mail"
|
"github.com/drone/drone/pkg/mail"
|
||||||
. "github.com/drone/drone/pkg/model"
|
. "github.com/drone/drone/pkg/model"
|
||||||
"github.com/drone/go-github/github"
|
"github.com/drone/go-github/github"
|
||||||
|
"log"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -134,6 +135,15 @@ func (b *BuildTask) execute() error {
|
||||||
builder.Key = []byte(b.Repo.PrivateKey)
|
builder.Key = []byte(b.Repo.PrivateKey)
|
||||||
builder.Stdout = buf
|
builder.Stdout = buf
|
||||||
builder.Timeout = 300 * time.Minute
|
builder.Timeout = 300 * time.Minute
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
// update the status of the commit using the
|
||||||
|
// GitHub status API.
|
||||||
|
if err := updateGitHubStatus(b.Repo, b.Commit); err != nil {
|
||||||
|
log.Printf("error updating github status: %s\n", err.Error())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
buildErr := builder.Run()
|
buildErr := builder.Run()
|
||||||
|
|
||||||
b.Build.Finished = time.Now().UTC()
|
b.Build.Finished = time.Now().UTC()
|
||||||
|
@ -181,12 +191,6 @@ func (b *BuildTask) execute() error {
|
||||||
b.Script.Notifications.Send(context)
|
b.Script.Notifications.Send(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the status of the commit using the
|
|
||||||
// GitHub status API.
|
|
||||||
if err := updateGitHubStatus(b.Repo, b.Commit); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue