Skip to content

feat: [PIPE-25660]: Handling for pipeline hook #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a8cb0ba
feat: [PIPE-25660]: Handling for pipeline hook
shivamnegi94 Mar 10, 2025
fbe0f09
feat: [PIPE-25660]: Added the parse for Gitlab pipeline event
shivamnegi94 Mar 11, 2025
69aa4bf
feat: [PIPE-25660]: Added the parse for Gitlab pipeline event
shivamnegi94 Mar 11, 2025
ee4c354
feat: [PIPE-25660]: Added the parse for Gitlab pipeline event
shivamnegi94 Mar 11, 2025
ccaa9d4
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Mar 25, 2025
c8daad0
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Mar 25, 2025
21dd005
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Mar 25, 2025
f0cb699
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Mar 25, 2025
6624e26
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Mar 26, 2025
9ac023f
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Mar 26, 2025
c9c11b9
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Mar 26, 2025
8c5694c
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Mar 26, 2025
6af00f7
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Mar 27, 2025
58d5b99
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Mar 27, 2025
9888aef
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Mar 27, 2025
cd95a1d
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Apr 1, 2025
93fd524
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Apr 4, 2025
a983aaa
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Apr 8, 2025
4c46b67
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Apr 8, 2025
a2deb0d
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Apr 9, 2025
d129799
feat: [PIPE-25660]: Support for pipeline hook event
shivamnegi94 Apr 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions scm/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,66 @@ func (v Visibility) String() (s string) {
}
}

// Status defines an enum for execution status
type ExecutionStatus int

const (
StatusUnknown ExecutionStatus = iota
StatusPending
StatusRunning
StatusSuccess
StatusFailed
StatusCanceled
)

// String returns the string representation of ExecutionStatus.
func (k ExecutionStatus) String() string {
switch k {
case StatusSuccess:
return "success"
case StatusPending:
return "pending"
case StatusRunning:
return "running"
case StatusFailed:
return "failed"
case StatusCanceled:
return "canceled"
case StatusUnknown:
return "Unknown"
default:
return "unsupported"
}
}

// MarshalJSON returns the JSON-encoded Action.
func (k ExecutionStatus) MarshalJSON() ([]byte, error) {
return json.Marshal(k.String())
}

// UnmarshalJSON unmarshales the JSON-encoded ExecutionStatus.
func (k *ExecutionStatus) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return err
}
switch s {
case StatusSuccess.String():
*k = StatusSuccess
case StatusPending.String():
*k = StatusPending
case StatusPending.String():
*k = StatusPending
case StatusRunning.String():
*k = StatusRunning
case StatusFailed.String():
*k = StatusFailed
case StatusCanceled.String():
*k = StatusCanceled
default:
*k = StatusUnknown
}
return nil
}

const SearchTimeFormat = "2006-01-02T15:04:05Z"
175 changes: 175 additions & 0 deletions scm/driver/bitbucket/testdata/webhooks/pipeline_hook_created.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
{
"repository": {
"type": "repository",
"full_name": "automationtestharness/testrepo",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo"
},
"html": {
"href": "https://bitbucket.org/automationtestharness/testrepo"
},
"avatar": {
"href": "https://bytebucket.org/ravatar/%7B2b922c6d-3824-4e91-a7be-90c8b8392f84%7D?ts=default"
}
},
"name": "testRepo",
"scm": "git",
"website": null,
"owner": {
"display_name": "Automationtestharness",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/workspaces/%7B612f7b18-b167-4bff-8ee9-d43570117ff1%7D"
},
"avatar": {
"href": "https://bitbucket.org/account/automationtestharness/avatar/"
},
"html": {
"href": "https://bitbucket.org/%7B612f7b18-b167-4bff-8ee9-d43570117ff1%7D/"
}
},
"type": "team",
"uuid": "{612f7b18-b167-4bff-8ee9-d43570117ff1}",
"username": "automationtestharness"
},
"workspace": {
"type": "workspace",
"uuid": "{612f7b18-b167-4bff-8ee9-d43570117ff1}",
"name": "Automationtestharness",
"slug": "automationtestharness",
"links": {
"avatar": {
"href": "https://bitbucket.org/workspaces/automationtestharness/avatar/?ts=1740994558"
},
"html": {
"href": "https://bitbucket.org/automationtestharness/"
},
"self": {
"href": "https://api.bitbucket.org/2.0/workspaces/automationtestharness"
}
}
},
"is_private": true,
"project": {
"type": "project",
"key": "TEST",
"uuid": "{af6d7f47-6ce6-48b6-9beb-d5ad6b674ba0}",
"name": "test",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/workspaces/automationtestharness/projects/TEST"
},
"html": {
"href": "https://bitbucket.org/automationtestharness/workspace/projects/TEST"
},
"avatar": {
"href": "https://bitbucket.org/automationtestharness/workspace/projects/TEST/avatar/32?ts=1738907820"
}
}
},
"uuid": "{2b922c6d-3824-4e91-a7be-90c8b8392f84}",
"parent": null
},
"actor": {
"display_name": "Automationtestharness",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/workspaces/%7B612f7b18-b167-4bff-8ee9-d43570117ff1%7D"
},
"avatar": {
"href": "https://bitbucket.org/account/automationtestharness/avatar/"
},
"html": {
"href": "https://bitbucket.org/%7B612f7b18-b167-4bff-8ee9-d43570117ff1%7D/"
}
},
"type": "team",
"uuid": "{612f7b18-b167-4bff-8ee9-d43570117ff1}",
"username": "automationtestharness"
},
"commit_status": {
"key": "3343801",
"type": "build",
"state": "INPROGRESS",
"name": "Pipeline #4 for main",
"refname": "main",
"commit": {
"type": "commit",
"hash": "bdf6fac0519ffd1562461eb82e018ff62efffbc9",
"date": "2025-03-24T08:48:15+00:00",
"author": {
"type": "author",
"raw": "Shivam Negi <[email protected]>",
"user": {
"display_name": "Shivam Negi",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/%7Bce7d5dfc-83c9-4878-beaf-7b91610e104a%7D"
},
"avatar": {
"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"
},
"html": {
"href": "https://bitbucket.org/%7Bce7d5dfc-83c9-4878-beaf-7b91610e104a%7D/"
}
},
"type": "user",
"uuid": "{ce7d5dfc-83c9-4878-beaf-7b91610e104a}",
"account_id": "601ba1bdb7bda90068ed5d1b",
"nickname": "Shivam Negi"
}
},
"message": "Merged in Shivam-Negi/testyaml-edited-online-with-bitbucket-1742806076994 (pull request #13)\n\ntest.yaml edited online with Bitbucket\n",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/commit/bdf6fac0519ffd1562461eb82e018ff62efffbc9"
},
"html": {
"href": "https://bitbucket.org/automationtestharness/testrepo/commits/bdf6fac0519ffd1562461eb82e018ff62efffbc9"
},
"diff": {
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/diff/bdf6fac0519ffd1562461eb82e018ff62efffbc9"
},
"approve": {
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/commit/bdf6fac0519ffd1562461eb82e018ff62efffbc9/approve"
},
"comments": {
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/commit/bdf6fac0519ffd1562461eb82e018ff62efffbc9/comments"
},
"statuses": {
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/commit/bdf6fac0519ffd1562461eb82e018ff62efffbc9/statuses"
}
}
},
"url": "https://bitbucket.org/automationtestharness/testrepo/addon/pipelines/home#!/results/4",
"repository": {
"type": "repository",
"full_name": "automationtestharness/testrepo",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo"
},
"html": {
"href": "https://bitbucket.org/automationtestharness/testrepo"
},
"avatar": {
"href": "https://bytebucket.org/ravatar/%7B2b922c6d-3824-4e91-a7be-90c8b8392f84%7D?ts=default"
}
},
"name": "testRepo",
"uuid": "{2b922c6d-3824-4e91-a7be-90c8b8392f84}"
},
"description": "",
"created_on": "2025-03-24T08:48:56.572438+00:00",
"updated_on": "2025-03-24T08:48:56.572450+00:00",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/commit/bdf6fac0519ffd1562461eb82e018ff62efffbc9/statuses/build/3343801"
},
"commit": {
"href": "https://api.bitbucket.org/2.0/repositories/automationtestharness/testrepo/commit/bdf6fac0519ffd1562461eb82e018ff62efffbc9"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"Repo": {
"ID": "{2b922c6d-3824-4e91-a7be-90c8b8392f84}",
"Namespace": "automationtestharness",
"Name": "testrepo",
"Clone": "https://bitbucket.org/automationtestharness/testrepo",
"CloneSSH": "",
"Branch": "main",
"Private": true
},
"Commit": {
"Sha": "bdf6fac0519ffd1562461eb82e018ff62efffbc9",
"Message": "Merged in Shivam-Negi/testyaml-edited-online-with-bitbucket-1742806076994 (pull request #13)\n\ntest.yaml edited online with Bitbucket\n",
"Author": {
"Name": "Shivam Negi",
"Email": "[email protected]",
"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"
},
"Committer": {
"Name": "Shivam Negi",
"Email": "[email protected]",
"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"
},
"Link": "https://bitbucket.org/automationtestharness/testrepo/commits/bdf6fac0519ffd1562461eb82e018ff62efffbc9"
},
"Execution": {
"Number": 4,
"Status": "running",
"Created": "2025-03-24T08:48:56.572438+00:00",
"URL": "https://bitbucket.org/automationtestharness/testrepo/addon/pipelines/home#!/results/4"
},
"Sender": {
"Login": "automationtestharness",
"Name": "Automationtestharness",
"Email": "",
"Avatar": "https://bitbucket.org/account/automationtestharness/avatar/",
"ID": "{612f7b18-b167-4bff-8ee9-d43570117ff1}"
}
}
Loading