-
Notifications
You must be signed in to change notification settings - Fork 423
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
Fix bitbucket server example when both SSH and HTTPS enabled #1641
Conversation
/kind bug |
@@ -8,4 +8,6 @@ spec: | |||
- name: gitrevision | |||
value: $(body.changes[0].ref.displayId) | |||
- name: gitrepositoryurl | |||
value: $(body.repository.links.clone[0].href) | |||
value: $(body.pullRequest.fromRef.repository.links.clone[?(@.name=="ssh")].href) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any reference payload data where i can look this syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here in Go struct: https://pkg.go.dev/github.com/suhaibmujahid/go-bitbucket-server/bitbucket#PullRequest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the operator, this is correct except for the part about handling ssh and https.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous expression is for a push-event payload, the new one is for pullreq-event payload.
For push event the json path is:
'$(body.repository.links.clone[?(@.name=="ssh")].href)'
Atlassian payload documentation is inconclusive, here's an example of pullrequest event payload with values edited:
{
"eventKey": "pr:merged",
"date": "2023-01-01T14:46:51+0000",
"actor": {
"name": "myuser",
"emailAddress": "user.name@example.com",
"id": 1,
"displayName": "User Name",
"active": true,
"slug": "myuser",
"type": "NORMAL",
"links": {
"self": [{
"href": "https://bitbucket.example.com/users/myuser"
}]
}
},
"pullRequest": {
"id": 1,
"version": 2,
"title": "readme.md edited online with Bitbucket",
"state": "MERGED",
"open": false,
"closed": true,
"createdDate": 1693572405591,
"updatedDate": 1693572410874,
"closedDate": 1693572410874,
"fromRef": {
"id": "refs/heads/myuser/readmemd-1693572398245",
"displayId": "myuser/readmemd-1693572398245",
"latestCommit": "<commit-id>",
"type": "BRANCH",
"repository": {
"slug": "myreposlug",
"id": 1234,
"name": "myrepo",
"description": "My repo",
"hierarchyId": "<hiearchyId>",
"scmId": "git",
"state": "AVAILABLE",
"statusMessage": "Available",
"forkable": true,
"project": {
"key": "~MYUSER",
"id": 123,
"name": "User Name",
"type": "PERSONAL",
"owner": {
"name": "username",
"emailAddress": "user.name@example.com",
"id": 1234,
"displayName": "User Name",
"active": true,
"slug": "myuser",
"type": "NORMAL",
"links": {
"self": [{
"href": "https://bitbucket.example.com/users/myuser"
}]
}
},
"links": {
"self": [{
"href": "https://bitbucket.example.com/users/myuser"
}]
}
},
"public": false,
"links": {
"clone": [{
"href": "https://bitbucket.example.com/scm/myprojec/myrepo.git",
"name": "http"
}, {
"href": "ssh://git@bitbucket.example.com:8123/~myuser/myrepo.git",
"name": "ssh"
}],
"self": [{
"href": "https://bitbucket.example.com/users/myuser/repos/myrepo/browse"
}]
}
}
},
"toRef": {
"id": "refs/heads/main",
"displayId": "main",
"latestCommit": "<commitid>",
"type": "BRANCH",
"repository": {
"slug": "myrepo",
"id": 1234,
"name": "myrepo",
"description": "Repo description",
"hierarchyId": "<hiearchy id>",
"scmId": "git",
"state": "AVAILABLE",
"statusMessage": "Available",
"forkable": true,
"project": {
"key": "~MYUSER",
"id": 123,
"name": "User Name",
"type": "PERSONAL",
"owner": {
"name": "username",
"emailAddress": "user.name@example.com",
"id": 123,
"displayName": "User Name",
"active": true,
"slug": "myuser",
"type": "NORMAL",
"links": {
"self": [{
"href": "https://bitbucket.example.com/users/myuser"
}]
}
},
"links": {
"self": [{
"href": "https://bitbucket.example.com/users/myuser"
}]
}
},
"public": false,
"links": {
"clone": [{
"href": "https://bitbucket.example.com/scm/myrepo/myrepo.git",
"name": "http"
}, {
"href": "ssh://git@bitbucket.example.com:8123/~myuser/myrepo.git",
"name": "ssh"
}],
"self": [{
"href": "https://bitbucket.example.com/users/myuser/repos/myrepo/browse"
}]
}
}
},
"locked": false,
"author": {
"user": {
"name": "myuser",
"emailAddress": "user.name@example.com",
"id": 1234,
"displayName": "User Name",
"active": true,
"slug": "username",
"type": "NORMAL",
"links": {
"self": [{
"href": "https://bitbucket.example.com/users/myuser"
}]
}
},
"role": "AUTHOR",
"approved": false,
"status": "UNAPPROVED"
},
"reviewers": [],
"participants": [],
"properties": {
"mergeCommit": {
"displayId": "<displayid>",
"id": "<commitid>"
}
},
"links": {
"self": [{
"href": "https://bitbucket.example.com/users/myuser/repos/myrepo/pull-requests/1"
}]
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a sample payload for a push event (refs_changed):
{
"eventKey": "repo:refs_changed",
"date": "2023-03-30T10:30:29+0200",
"actor": {
"name": "user",
"emailAddress": "user.name@example.com",
"id": 1234,
"displayName": "User Name",
"active": true,
"slug": "user",
"type": "NORMAL",
"links": {
"self": [{
"href": ["https://bitbucket.example.com/mains/user"]
}]
}
},
"repository": {
"slug": "myrepo",
"id": 1234,
"name": "myrepo",
"description": "Repo description",
"hierarchyId": "<hiearchy id>",
"scmId": "git",
"state": "AVAILABLE",
"statusMessage": "Available",
"forkable": true,
"project": {
"key": "myproject",
"id": 287,
"name": "My Project",
"description": "Project description",
"public": false,
"type": "NORMAL",
"links": {
"self": [{
"href": "https://bitbucket.example.com/projects/myproject"
}]
}
},
"public": false,
"links": {
"clone": [{
"href": "https://bitbucket.example.com/scm/myproject/myrepo.git",
"name": "http"
}, {
"href": "ssh://git@bitbucket.example.com:8123/myproject/myrepo.git",
"name": "ssh"
}],
"self": [{
"href": "https://bitbucket.example.com/projects/myproject/repos/myrepo/browse"
}]
}
},
"changes": [{
"ref": {
"id": "refs/heads/master",
"displayId": "master",
"type": "BRANCH"
},
"refId": "refs/heads/master",
"fromHash": "<commithash>",
"toHash": "<commithash>",
"type": "UPDATE"
}]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have fixed the formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have fixed it for refs/push now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous expression is for a push-event payload, the new one is for pullreq-event payload.
For push event the json path is:
'$(body.repository.links.clone[?(@.name=="ssh")].href)'
Atlassian payload documentation is inconclusive, here's an example of pullrequest event payload with values edited:
{ "eventKey": "pr:merged", "date": "2023-01-01T14:46:51+0000", "actor": { "name": "myuser", "emailAddress": "user.name@example.com", "id": 1, "displayName": "User Name", "active": true, "slug": "myuser", "type": "NORMAL", "links": { "self": [{ "href": "https://bitbucket.example.com/users/myuser" }] } }, "pullRequest": { "id": 1, "version": 2, "title": "readme.md edited online with Bitbucket", "state": "MERGED", "open": false, "closed": true, "createdDate": 1693572405591, "updatedDate": 1693572410874, "closedDate": 1693572410874, "fromRef": { "id": "refs/heads/myuser/readmemd-1693572398245", "displayId": "myuser/readmemd-1693572398245", "latestCommit": "<commit-id>", "type": "BRANCH", "repository": { "slug": "myreposlug", "id": 1234, "name": "myrepo", "description": "My repo", "hierarchyId": "<hiearchyId>", "scmId": "git", "state": "AVAILABLE", "statusMessage": "Available", "forkable": true, "project": { "key": "~MYUSER", "id": 123, "name": "User Name", "type": "PERSONAL", "owner": { "name": "username", "emailAddress": "user.name@example.com", "id": 1234, "displayName": "User Name", "active": true, "slug": "myuser", "type": "NORMAL", "links": { "self": [{ "href": "https://bitbucket.example.com/users/myuser" }] } }, "links": { "self": [{ "href": "https://bitbucket.example.com/users/myuser" }] } }, "public": false, "links": { "clone": [{ "href": "https://bitbucket.example.com/scm/myprojec/myrepo.git", "name": "http" }, { "href": "ssh://git@bitbucket.example.com:8123/~myuser/myrepo.git", "name": "ssh" }], "self": [{ "href": "https://bitbucket.example.com/users/myuser/repos/myrepo/browse" }] } } }, "toRef": { "id": "refs/heads/main", "displayId": "main", "latestCommit": "<commitid>", "type": "BRANCH", "repository": { "slug": "myrepo", "id": 1234, "name": "myrepo", "description": "Repo description", "hierarchyId": "<hiearchy id>", "scmId": "git", "state": "AVAILABLE", "statusMessage": "Available", "forkable": true, "project": { "key": "~MYUSER", "id": 123, "name": "User Name", "type": "PERSONAL", "owner": { "name": "username", "emailAddress": "user.name@example.com", "id": 123, "displayName": "User Name", "active": true, "slug": "myuser", "type": "NORMAL", "links": { "self": [{ "href": "https://bitbucket.example.com/users/myuser" }] } }, "links": { "self": [{ "href": "https://bitbucket.example.com/users/myuser" }] } }, "public": false, "links": { "clone": [{ "href": "https://bitbucket.example.com/scm/myrepo/myrepo.git", "name": "http" }, { "href": "ssh://git@bitbucket.example.com:8123/~myuser/myrepo.git", "name": "ssh" }], "self": [{ "href": "https://bitbucket.example.com/users/myuser/repos/myrepo/browse" }] } } }, "locked": false, "author": { "user": { "name": "myuser", "emailAddress": "user.name@example.com", "id": 1234, "displayName": "User Name", "active": true, "slug": "username", "type": "NORMAL", "links": { "self": [{ "href": "https://bitbucket.example.com/users/myuser" }] } }, "role": "AUTHOR", "approved": false, "status": "UNAPPROVED" }, "reviewers": [], "participants": [], "properties": { "mergeCommit": { "displayId": "<displayid>", "id": "<commitid>" } }, "links": { "self": [{ "href": "https://bitbucket.example.com/users/myuser/repos/myrepo/pull-requests/1" }] } } }
Thank you @af-wieda 👍
/retest Build tests shouldn't fail. The integration test failing is correct. |
Fix the bitbucket server example when it has both SSH and HTTPS.
/retest |
/lgtm |
fixes #1640 |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dibyom The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fix the bitbucket server example when it has both SSH and HTTPS.
Changes
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes