Skip to content

Commit

Permalink
fix(#330): fix panic error when abort pipeline which has no log (#364)
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue.

Cherry pick #331 into release-0.3

**What this PR does / why we need it**:

Manually cherry pick #331 into release-0.3:
#331: fix(#330): fix panic error when abort pipeline which has no log

**Which issue(s) this PR fixes** *(optional, close the issue(s) when PR gets merged)*:

Fixes #330

**Special notes for your reviewer**:

/cc @zhujian7 

**Release note**:

```release-note
NONE
```
  • Loading branch information
supereagle authored and caicloud-bot committed Mar 4, 2018
1 parent 49f73b9 commit c277670
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions event/event.go
Expand Up @@ -144,11 +144,15 @@ func postHookEvent(event *api.Event) {

// generateAbortedStateLog generates aborted state log for last stage to illustrate that the record is aborted.
func generateAbortedStateLog(log string) string {
subLogs := log[strings.LastIndex(log, "\nstep: "):]
i := strings.Index(subLogs, " state: ")
additionalLog := subLogs[1:i+8] + "aborted\n"
if strings.Contains(log, "\nstep: ") && strings.Contains(log, " state: ") {
subLogs := log[strings.LastIndex(log, "\nstep: "):]
i := strings.Index(subLogs, " state: ")
additionalLog := subLogs[1:i+8] + "aborted\n"

return additionalLog
return additionalLog
}

return ""
}

// createServiceHander is the create service handler.
Expand Down

0 comments on commit c277670

Please sign in to comment.