gitlab: add Job Hook
This commit is contained in:
parent
6b5934628a
commit
6b337d562a
|
@ -92,6 +92,11 @@ func init() {
|
||||||
err = libHTTP.Read(r, &pl)
|
err = libHTTP.Read(r, &pl)
|
||||||
msg = pl.String()
|
msg = pl.String()
|
||||||
|
|
||||||
|
case JobEvents:
|
||||||
|
var pl JobEventPayload
|
||||||
|
err = libHTTP.Read(r, &pl)
|
||||||
|
msg = pl.String()
|
||||||
|
|
||||||
case SystemEvents:
|
case SystemEvents:
|
||||||
var data map[string]interface{}
|
var data map[string]interface{}
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
|
@ -18,6 +18,7 @@ const (
|
||||||
MergeRequestEvents Event = "Merge Request Hook"
|
MergeRequestEvents Event = "Merge Request Hook"
|
||||||
WikiPageEvents Event = "Wiki Page Hook"
|
WikiPageEvents Event = "Wiki Page Hook"
|
||||||
PipelineEvents Event = "Pipeline Hook"
|
PipelineEvents Event = "Pipeline Hook"
|
||||||
|
JobEvents Event = "Job Hook"
|
||||||
BuildEvents Event = "Build Hook"
|
BuildEvents Event = "Build Hook"
|
||||||
SystemEvents Event = "System Hook"
|
SystemEvents Event = "System Hook"
|
||||||
)
|
)
|
||||||
|
@ -155,12 +156,12 @@ type PipelineEventPayload struct {
|
||||||
User User `json:"user"`
|
User User `json:"user"`
|
||||||
Project Project `json:"project"`
|
Project Project `json:"project"`
|
||||||
Commit Commit `json:"commit"`
|
Commit Commit `json:"commit"`
|
||||||
ObjectAttributes ObjectAttributes `json:"object_attributes"`
|
ObjectAttributes map[string]interface{} `json:"object_attributes"`
|
||||||
Builds []Build `json:"builds"`
|
Builds []Build `json:"builds"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pl *PipelineEventPayload) String() string {
|
func (pl *PipelineEventPayload) String() string {
|
||||||
return fmt.Sprintf("[%s] %s: started %d builds by %s of %s", pl.Project.Name, PipelineEvents, len(pl.Builds), pl.User.Name, pl.Commit.String())
|
return fmt.Sprintf("[%s] %s: started %d builds by %s of %s => %s (%s)", pl.Project.Name, PipelineEvents, len(pl.Builds), pl.User.Name, pl.Commit.Ref, pl.Commit.Message, pl.Commit.SHA)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommentEventPayload contains the information for GitLab's comment event
|
// CommentEventPayload contains the information for GitLab's comment event
|
||||||
|
@ -181,6 +182,35 @@ func (pl *CommentEventPayload) String() string {
|
||||||
return fmt.Sprintf("[%s] %s: comment PR !%d by %s of %s", pl.Project.Name, CommentEvents, pl.MergeRequest.ID, pl.User.Name, pl.Commit.String())
|
return fmt.Sprintf("[%s] %s: comment PR !%d by %s of %s", pl.Project.Name, CommentEvents, pl.MergeRequest.ID, pl.User.Name, pl.Commit.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JobEventPayload contains the information for GitLab's build status change event
|
||||||
|
type JobEventPayload struct {
|
||||||
|
ObjectKind string `json:"object_kind"`
|
||||||
|
Ref string `json:"ref"`
|
||||||
|
Tag bool `json:"tag"`
|
||||||
|
BeforeSHA string `json:"before_sha"`
|
||||||
|
SHA string `json:"sha"`
|
||||||
|
BuildID int64 `json:"build_id"`
|
||||||
|
BuildName string `json:"build_name"`
|
||||||
|
BuildStage string `json:"build_stage"`
|
||||||
|
BuildStatus string `json:"build_status"`
|
||||||
|
BuildStartedAt customTime `json:"build_started_at"`
|
||||||
|
BuildFinishedAt customTime `json:"build_finished_at"`
|
||||||
|
BuildDuration int64 `json:"build_duration"`
|
||||||
|
BuildAllowFailure bool `json:"build_allow_failure"`
|
||||||
|
BuildFailureReason string `json:"build_failure_reason"`
|
||||||
|
PipelineID int64 `json:"pipeline_id"`
|
||||||
|
ProjectID int64 `json:"project_id"`
|
||||||
|
ProjectName string `json:"project_name"`
|
||||||
|
User User `json:"user"`
|
||||||
|
Commit BuildCommit `json:"commit"`
|
||||||
|
Repository Repository `json:"repository"`
|
||||||
|
Runner Runner `json:"runner"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pl *JobEventPayload) String() string {
|
||||||
|
return fmt.Sprintf("[%s] %s: %s build %d (in pipeline %d) for %s => %s", pl.ProjectName, BuildEvents, pl.BuildStatus, pl.BuildID, pl.PipelineID, pl.Ref, pl.SHA)
|
||||||
|
}
|
||||||
|
|
||||||
// BuildEventPayload contains the information for GitLab's build status change event
|
// BuildEventPayload contains the information for GitLab's build status change event
|
||||||
type BuildEventPayload struct {
|
type BuildEventPayload struct {
|
||||||
ObjectKind string `json:"object_kind"`
|
ObjectKind string `json:"object_kind"`
|
||||||
|
|
Loading…
Reference in New Issue