Skip to content

Commit e91781e

Browse files
authored
feat: [PIPE-25660]: Handling for pipeline hook (#330)
* feat: [PIPE-25660]: Handling for pipeline hook * feat: [PIPE-25660]: Added the parse for Gitlab pipeline event * feat: [PIPE-25660]: Added the parse for Gitlab pipeline event * feat: [PIPE-25660]: Added the parse for Gitlab pipeline event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event * feat: [PIPE-25660]: Support for pipeline hook event
1 parent 4bcbe7b commit e91781e

20 files changed

+1632
-4
lines changed

scm/const.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,4 +283,66 @@ func (v Visibility) String() (s string) {
283283
}
284284
}
285285

286+
// Status defines an enum for execution status
287+
type ExecutionStatus int
288+
289+
const (
290+
StatusUnknown ExecutionStatus = iota
291+
StatusPending
292+
StatusRunning
293+
StatusSuccess
294+
StatusFailed
295+
StatusCanceled
296+
)
297+
298+
// String returns the string representation of ExecutionStatus.
299+
func (k ExecutionStatus) String() string {
300+
switch k {
301+
case StatusSuccess:
302+
return "success"
303+
case StatusPending:
304+
return "pending"
305+
case StatusRunning:
306+
return "running"
307+
case StatusFailed:
308+
return "failed"
309+
case StatusCanceled:
310+
return "canceled"
311+
case StatusUnknown:
312+
return "Unknown"
313+
default:
314+
return "unsupported"
315+
}
316+
}
317+
318+
// MarshalJSON returns the JSON-encoded Action.
319+
func (k ExecutionStatus) MarshalJSON() ([]byte, error) {
320+
return json.Marshal(k.String())
321+
}
322+
323+
// UnmarshalJSON unmarshales the JSON-encoded ExecutionStatus.
324+
func (k *ExecutionStatus) UnmarshalJSON(data []byte) error {
325+
var s string
326+
if err := json.Unmarshal(data, &s); err != nil {
327+
return err
328+
}
329+
switch s {
330+
case StatusSuccess.String():
331+
*k = StatusSuccess
332+
case StatusPending.String():
333+
*k = StatusPending
334+
case StatusPending.String():
335+
*k = StatusPending
336+
case StatusRunning.String():
337+
*k = StatusRunning
338+
case StatusFailed.String():
339+
*k = StatusFailed
340+
case StatusCanceled.String():
341+
*k = StatusCanceled
342+
default:
343+
*k = StatusUnknown
344+
}
345+
return nil
346+
}
347+
286348
const SearchTimeFormat = "2006-01-02T15:04:05Z"
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
{
2+
"repository": {
3+
"type": "repository",
4+
"full_name": "automationtestharness/testrepo",
5+
"links": {
6+
"self": {
7+
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo"
8+
},
9+
"html": {
10+
"href": "https://bitbucket.org/automationtestharness/testrepo"
11+
},
12+
"avatar": {
13+
"href": "https://bytebucket.org/ravatar/%7B2b922c6d-3824-4e91-a7be-90c8b8392f84%7D?ts=default"
14+
}
15+
},
16+
"name": "testRepo",
17+
"scm": "git",
18+
"website": null,
19+
"owner": {
20+
"display_name": "Automationtestharness",
21+
"links": {
22+
"self": {
23+
"href": "https://api.bitbucket.org/2.0/workspaces/%7B612f7b18-b167-4bff-8ee9-d43570117ff1%7D"
24+
},
25+
"avatar": {
26+
"href": "https://bitbucket.org/account/automationtestharness/avatar/"
27+
},
28+
"html": {
29+
"href": "https://bitbucket.org/%7B612f7b18-b167-4bff-8ee9-d43570117ff1%7D/"
30+
}
31+
},
32+
"type": "team",
33+
"uuid": "{612f7b18-b167-4bff-8ee9-d43570117ff1}",
34+
"username": "automationtestharness"
35+
},
36+
"workspace": {
37+
"type": "workspace",
38+
"uuid": "{612f7b18-b167-4bff-8ee9-d43570117ff1}",
39+
"name": "Automationtestharness",
40+
"slug": "automationtestharness",
41+
"links": {
42+
"avatar": {
43+
"href": "https://bitbucket.org/workspaces/automationtestharness/avatar/?ts=1740994558"
44+
},
45+
"html": {
46+
"href": "https://bitbucket.org/automationtestharness/"
47+
},
48+
"self": {
49+
"href": "https://api.bitbucket.org/2.0/workspaces/automationtestharness"
50+
}
51+
}
52+
},
53+
"is_private": true,
54+
"project": {
55+
"type": "project",
56+
"key": "TEST",
57+
"uuid": "{af6d7f47-6ce6-48b6-9beb-d5ad6b674ba0}",
58+
"name": "test",
59+
"links": {
60+
"self": {
61+
"href": "https://api.bitbucket.org/2.0/workspaces/automationtestharness/projects/TEST"
62+
},
63+
"html": {
64+
"href": "https://bitbucket.org/automationtestharness/workspace/projects/TEST"
65+
},
66+
"avatar": {
67+
"href": "https://bitbucket.org/automationtestharness/workspace/projects/TEST/avatar/32?ts=1738907820"
68+
}
69+
}
70+
},
71+
"uuid": "{2b922c6d-3824-4e91-a7be-90c8b8392f84}",
72+
"parent": null
73+
},
74+
"actor": {
75+
"display_name": "Automationtestharness",
76+
"links": {
77+
"self": {
78+
"href": "https://api.bitbucket.org/2.0/workspaces/%7B612f7b18-b167-4bff-8ee9-d43570117ff1%7D"
79+
},
80+
"avatar": {
81+
"href": "https://bitbucket.org/account/automationtestharness/avatar/"
82+
},
83+
"html": {
84+
"href": "https://bitbucket.org/%7B612f7b18-b167-4bff-8ee9-d43570117ff1%7D/"
85+
}
86+
},
87+
"type": "team",
88+
"uuid": "{612f7b18-b167-4bff-8ee9-d43570117ff1}",
89+
"username": "automationtestharness"
90+
},
91+
"commit_status": {
92+
"key": "3343801",
93+
"type": "build",
94+
"state": "INPROGRESS",
95+
"name": "Pipeline #4 for main",
96+
"refname": "main",
97+
"commit": {
98+
"type": "commit",
99+
"hash": "bdf6fac0519ffd1562461eb82e018ff62efffbc9",
100+
"date": "2025-03-24T08:48:15+00:00",
101+
"author": {
102+
"type": "author",
103+
"raw": "Shivam Negi <[email protected]>",
104+
"user": {
105+
"display_name": "Shivam Negi",
106+
"links": {
107+
"self": {
108+
"href": "https://api.bitbucket.org/2.0/users/%7Bce7d5dfc-83c9-4878-beaf-7b91610e104a%7D"
109+
},
110+
"avatar": {
111+
"href": "https://secure.gravatar.com/avatar/39b64ab2df0f61fcce00db05f94c600b?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSN-2.png"
112+
},
113+
"html": {
114+
"href": "https://bitbucket.org/%7Bce7d5dfc-83c9-4878-beaf-7b91610e104a%7D/"
115+
}
116+
},
117+
"type": "user",
118+
"uuid": "{ce7d5dfc-83c9-4878-beaf-7b91610e104a}",
119+
"account_id": "601ba1bdb7bda90068ed5d1b",
120+
"nickname": "Shivam Negi"
121+
}
122+
},
123+
"message": "Merged in Shivam-Negi/testyaml-edited-online-with-bitbucket-1742806076994 (pull request #13)\n\ntest.yaml edited online with Bitbucket\n",
124+
"links": {
125+
"self": {
126+
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/commit/bdf6fac0519ffd1562461eb82e018ff62efffbc9"
127+
},
128+
"html": {
129+
"href": "https://bitbucket.org/automationtestharness/testrepo/commits/bdf6fac0519ffd1562461eb82e018ff62efffbc9"
130+
},
131+
"diff": {
132+
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/diff/bdf6fac0519ffd1562461eb82e018ff62efffbc9"
133+
},
134+
"approve": {
135+
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/commit/bdf6fac0519ffd1562461eb82e018ff62efffbc9/approve"
136+
},
137+
"comments": {
138+
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/commit/bdf6fac0519ffd1562461eb82e018ff62efffbc9/comments"
139+
},
140+
"statuses": {
141+
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/commit/bdf6fac0519ffd1562461eb82e018ff62efffbc9/statuses"
142+
}
143+
}
144+
},
145+
"url": "https://bitbucket.org/automationtestharness/testrepo/addon/pipelines/home#!/results/4",
146+
"repository": {
147+
"type": "repository",
148+
"full_name": "automationtestharness/testrepo",
149+
"links": {
150+
"self": {
151+
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo"
152+
},
153+
"html": {
154+
"href": "https://bitbucket.org/automationtestharness/testrepo"
155+
},
156+
"avatar": {
157+
"href": "https://bytebucket.org/ravatar/%7B2b922c6d-3824-4e91-a7be-90c8b8392f84%7D?ts=default"
158+
}
159+
},
160+
"name": "testRepo",
161+
"uuid": "{2b922c6d-3824-4e91-a7be-90c8b8392f84}"
162+
},
163+
"description": "",
164+
"created_on": "2025-03-24T08:48:56.572438+00:00",
165+
"updated_on": "2025-03-24T08:48:56.572450+00:00",
166+
"links": {
167+
"self": {
168+
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/commit/bdf6fac0519ffd1562461eb82e018ff62efffbc9/statuses/build/3343801"
169+
},
170+
"commit": {
171+
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/commit/bdf6fac0519ffd1562461eb82e018ff62efffbc9"
172+
}
173+
}
174+
}
175+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"Repo": {
3+
"ID": "{2b922c6d-3824-4e91-a7be-90c8b8392f84}",
4+
"Namespace": "automationtestharness",
5+
"Name": "testrepo",
6+
"Clone": "https://bitbucket.org/automationtestharness/testrepo",
7+
"CloneSSH": "",
8+
"Branch": "main",
9+
"Private": true
10+
},
11+
"Commit": {
12+
"Sha": "bdf6fac0519ffd1562461eb82e018ff62efffbc9",
13+
"Message": "Merged in Shivam-Negi/testyaml-edited-online-with-bitbucket-1742806076994 (pull request #13)\n\ntest.yaml edited online with Bitbucket\n",
14+
"Author": {
15+
"Name": "Shivam Negi",
16+
"Email": "[email protected]",
17+
"Avatar": "https://secure.gravatar.com/avatar/39b64ab2df0f61fcce00db05f94c600b?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSN-2.png"
18+
},
19+
"Committer": {
20+
"Name": "Shivam Negi",
21+
"Email": "[email protected]",
22+
"Avatar": "https://secure.gravatar.com/avatar/39b64ab2df0f61fcce00db05f94c600b?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FSN-2.png"
23+
},
24+
"Link": "https://bitbucket.org/automationtestharness/testrepo/commits/bdf6fac0519ffd1562461eb82e018ff62efffbc9"
25+
},
26+
"Execution": {
27+
"Number": 4,
28+
"Status": "running",
29+
"Created": "2025-03-24T08:48:56.572438+00:00",
30+
"URL": "https://bitbucket.org/automationtestharness/testrepo/addon/pipelines/home#!/results/4"
31+
},
32+
"Sender": {
33+
"Login": "automationtestharness",
34+
"Name": "Automationtestharness",
35+
"Email": "",
36+
"Avatar": "https://bitbucket.org/account/automationtestharness/avatar/",
37+
"ID": "{612f7b18-b167-4bff-8ee9-d43570117ff1}"
38+
}
39+
}

0 commit comments

Comments
 (0)