Skip to content

Commit

Permalink
fix(schedule): better handling of commit status limit for schedule bu…
Browse files Browse the repository at this point in the history
…ild (#1046)

* scheduled build should be updated to github

* remove from post.go since schedule build doesnt receive webhood

---------

Co-authored-by: TimHuynh <tim.huynh@target.com>
  • Loading branch information
timhuynh94 and TimHuynh committed Jan 29, 2024
1 parent 4e438e1 commit b88749c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions api/build/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,12 @@ func CreateBuild(c *gin.Context) {

c.JSON(http.StatusCreated, input)

// send API call to set the status on the commit
err = scm.FromContext(c).Status(ctx, u, input, r.GetOrg(), r.GetName())
if err != nil {
logger.Errorf("unable to set commit status for build %s/%d: %v", r.GetFullName(), input.GetNumber(), err)
// send API call to set the status on the commit except for scheduled build
if input.GetEvent() != constants.EventSchedule {
err = scm.FromContext(c).Status(ctx, u, input, r.GetOrg(), r.GetName())
if err != nil {
logger.Errorf("unable to set commit status for build %s/%d: %v", r.GetFullName(), input.GetNumber(), err)
}
}

// determine queue route
Expand Down
5 changes: 3 additions & 2 deletions api/build/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,12 @@ func UpdateBuild(c *gin.Context) {
c.JSON(http.StatusOK, b)

// check if the build is in a "final" state
if b.GetStatus() == constants.StatusSuccess ||
// and if build is not a scheduled event
if (b.GetStatus() == constants.StatusSuccess ||
b.GetStatus() == constants.StatusFailure ||
b.GetStatus() == constants.StatusCanceled ||
b.GetStatus() == constants.StatusKilled ||
b.GetStatus() == constants.StatusError {
b.GetStatus() == constants.StatusError) && b.GetEvent() != constants.EventSchedule {
// send API call to capture the repo owner
u, err := database.FromContext(c).GetUser(ctx, r.GetUserID())
if err != nil {
Expand Down

0 comments on commit b88749c

Please sign in to comment.