Closed davidmichaelkarr closed 7 years ago
I created a notification with url like https://requestb.in/1g1fif31?${EVERYTHING_URL}
and got this recorded in requestb.in:
https://requestb.in/1g1fif31?inspect
PULL_REQUEST_MERGE_COMMIT:
PULL_REQUEST_AUTHOR_SLUG: admin
PULL_REQUEST_TO_REPO_NAME: rep_1
PULL_REQUEST_TO_ID: refs/heads/master
PULL_REQUEST_FROM_BRANCH: basic_branching
PULL_REQUEST_USER_EMAIL_ADDRESS: admin@example.com
PULL_REQUEST_REVIEWERS_UNAPPROVED_NAME:
PULL_REQUEST_REVIEWERS_APPROVED_SLUG:
PULL_REQUEST_REVIEWERS_UNAPPROVED_COUNT: 0
PULL_REQUEST_URL: http://localhost:7990/bitbucket/projects/PROJECT_1/repos/rep_1/pull-requests/1
PULL_REQUEST_AUTHOR_ID: 1
PULL_REQUEST_REVIEWERS_NEEDS_WORK_NAME:
PULL_REQUEST_ID: 1
PULL_REQUEST_TO_REPO_PROJECT_ID: 1
PULL_REQUEST_AUTHOR_NAME: admin
PULL_REQUEST_COMMENT_TEXT: min kommentar
PULL_REQUEST_REVIEWERS_APPROVED_NAME:
PULL_REQUEST_REVIEWERS_APPROVED_EMAIL:
PULL_REQUEST_FROM_REPO_SLUG: rep_1
BUTTON_FORM_DATA:
PULL_REQUEST_REVIEWERS_UNAPPROVED_SLUG:
PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT: 0
INJECTION_URL_VALUE:
PULL_REQUEST_REVIEWERS_EMAIL:
PULL_REQUEST_PREVIOUS_TO_HASH:
PULL_REQUEST_TO_HASH: 0a943a29376f2336b78312d99e65da17048951db
PULL_REQUEST_TO_REPO_SLUG: rep_1
PULL_REQUEST_TITLE: a modification on branch basic_branching
PULL_REQUEST_REVIEWERS_NEEDS_WORK_SLUG:
PULL_REQUEST_REVIEWERS_SLUG:
PULL_REQUEST_REVIEWERS_APPROVED_DISPLAY_NAME:
PULL_REQUEST_USER_NAME: admin
PULL_REQUEST_REVIEWERS:
PULL_REQUEST_AUTHOR_EMAIL: admin@example.com
PULL_REQUEST_AUTHOR_DISPLAY_NAME: Administrator
PULL_REQUEST_REVIEWERS_UNAPPROVED_EMAIL:
PULL_REQUEST_REVIEWERS_ID:
PULL_REQUEST_PARTICIPANTS_EMAIL:
PULL_REQUEST_REVIEWERS_UNAPPROVED_DISPLAY_NAME:
PULL_REQUEST_TO_HTTP_CLONE_URL: http://admin@localhost:7990/bitbucket/scm/project_1/rep_1.git
PULL_REQUEST_TO_REPO_ID: 1
PULL_REQUEST_REVIEWERS_APPROVED_COUNT: 0
PULL_REQUEST_FROM_REPO_NAME: rep_1
PULL_REQUEST_FROM_HTTP_CLONE_URL: http://admin@localhost:7990/bitbucket/scm/project_1/rep_1.git
PULL_REQUEST_COMMENT_ACTION: ADDED
PULL_REQUEST_FROM_ID: refs/heads/basic_branching
PULL_REQUEST_REVIEWERS_NEEDS_WORK_COUNT: 0
PULL_REQUEST_USER_DISPLAY_NAME: Administrator
PULL_REQUEST_TO_BRANCH: master
PULL_REQUEST_USER_GROUPS:
PULL_REQUEST_FROM_REPO_ID: 1
PULL_REQUEST_REVIEWERS_NEEDS_WORK_DISPLAY_NAME:
PULL_REQUEST_FROM_SSH_CLONE_URL: ssh://git@localhost:7999/project_1/rep_1.git
PULL_REQUEST_TO_SSH_CLONE_URL: ssh://git@localhost:7999/project_1/rep_1.git
PULL_REQUEST_TO_REPO_PROJECT_KEY: PROJECT_1
PULL_REQUEST_FROM_HASH: d6edcbf924697ab811a867421dab60d954ccad99
PULL_REQUEST_STATE: OPEN
PULL_REQUEST_USER_ID: 1
PULL_REQUEST_USER_SLUG: admin
PULL_REQUEST_ACTION: COMMENTED
PULL_REQUEST_REVIEWERS_NEEDS_WORK_EMAIL:
PULL_REQUEST_FROM_REPO_PROJECT_KEY: PROJECT_1
PULL_REQUEST_FROM_REPO_PROJECT_ID: 1
BUTTON_TRIGGER_TITLE:
PULL_REQUEST_VERSION: 0
PULL_REQUEST_PREVIOUS_FROM_HASH:
This is with Bitbucket Server 5.2.2 and latest plugin version. You should have same results even with BBS 4.x.
I'm not sure what "I created a notification" means. You had this integrated into a bitbucket repo and added a comment on a PR and this is what was produced?
Yes. Created a new notification, checked comment, added this URL, with GET. Created a comment in a PR. This is what it reported.
I would guess your problem is unrelated to the plugin. Firewall issue or configuration issue in target system (Jenkins?)...
Can the issue be closed?
Well, for this test I'm only using requestb.in, so it has nothing to do with jenkins. I just ensured that the proxy is set on the PRN, and it still made no difference.
And you can do the equivalent http invocation with curl from the machine running Bitbucket Server?
If only I had the godlike rights to do that. :) I'll add that request to the ticket on my end, which takes longer to get a response than it does from you.
I've changed the URL so that it points to a new Jenkins job that I just defined, using the same form as my other PRN, and the new one never fires when a comment is added to a review. There is no firewall between them.
There is nothing in you Bitbucket Server logs?
What, exactly, does your notification setttings look like? You can get it with REST from /bitbucket/rest/prnfb-admin/1.0/settings/notifications
.
I don't know about the logs. In this enterprise, I have to work through other people to get them to look at that.
Here's the output from that REST call:
[ { "headers": [], "method": "POST", "name": "Pull Request Creation", "password": "...", "projectKey": "ST_USL", "repositorySlug": "usl_monitor", "triggerIfCanMerge": "ALWAYS", "triggerIgnoreStateList": [], "triggers": [ "OPENED", "REOPENED", "UPDATED" ], "url": "http://sdt-usl2.vci.att.com:17723/jenkins/job/usl-monitor-build-pipeline/buildWithParameters?token=usl&cause=prn-create&JP_PullRequestTitle=${PULL_REQUEST_TITLE}&JP_CodeBranch=${PULL_REQUEST_FROM_BRANCH}&JP_PullRequestURL=${PULL_REQUEST_URL}", "user": "m84796@sharedservices.att.com", "uuid": "88329d8a-955f-4a7d-9985-9d02b231d926", "postContentEncoding": "NONE" }, { "headers": [], "method": "POST", "name": "Pull Request Creation", "password": "...", "projectKey": "ST_USL", "repositorySlug": "oce_usl", "triggerIfCanMerge": "ALWAYS", "triggerIgnoreStateList": [], "triggers": [ "OPENED", "REOPENED", "RESCOPED_FROM", "UPDATED" ], "url": "http://sdt-usl2.vci.att.com:17723/jenkins/job/unified-service-layer-build-pipeline/buildWithParameters?token=usl&cause=prn-create&JP_PullRequestTitle=${PULL_REQUEST_TITLE}&JP_CodeBranch=${PULL_REQUEST_FROM_BRANCH}&JP_PullRequestURL=${PULL_REQUEST_URL}", "user": "m84796@sharedservices.att.com", "uuid": "d26f0e24-17cf-42d1-abb2-9f36a4bc4445", "postContentEncoding": "NONE" }, { "headers": [], "method": "GET", "name": "pull request comments processor", "projectKey": "ST_USL", "proxyPort": 8080, "proxyServer": "one.proxy.att.com", "proxySchema": "http", "repositorySlug": "oce_usl", "triggerIfCanMerge": "ALWAYS", "triggerIgnoreStateList": [], "triggers": [ "COMMENTED" ], "url": "https://requestb.in/11hgfpf1?${EVERYTHING_URL}", "uuid": "c5e48c5d-0a8f-42b8-b827-630067c6008a", "postContentEncoding": "NONE" }, { "headers": [], "method": "GET", "name": "pull request comments processor", "projectKey": "ST_USL", "proxySchema": "http", "repositorySlug": "oce_usl", "triggerIfCanMerge": "ALWAYS", "triggerIgnoreStateList": [], "triggers": [ "COMMENTED" ], "url": "http://sdt-usl2.vci.att.com:17723/jenkins/job/comment-processor/buildWithParameters?${EVERYTHING_URL}", "uuid": "aed2e876-d760-4e72-bce9-b61d56d17d3f", "postContentEncoding": "NONE" }, { "headers": [], "method": "GET", "name": "pull request comments processor", "projectKey": "ST_USL", "proxySchema": "http", "repositorySlug": "oce_usl", "triggerIfCanMerge": "ALWAYS", "triggerIgnoreStateList": [], "triggers": [ "COMMENTED" ], "url": "http://sdt-usl2.vci.att.com:17723/jenkins/job/comment-processor/build?${EVERYTHING_URL}", "uuid": "b9cd8d37-80e1-475d-a636-99e0b6f34f3f", "postContentEncoding": "NONE" }, { "headers": [], "method": "GET", "name": "pull request comments processor", "password": "...", "projectKey": "ST_USL", "proxySchema": "http", "repositorySlug": "oce_usl", "triggerIfCanMerge": "ALWAYS", "triggerIgnoreStateList": [], "triggers": [ "COMMENTED" ], "url": "http://sdt-usl2.vci.att.com:17723/jenkins/job/comment-processor/build?${EVERYTHING_URL}", "user": "m84796@sharedservices.att.com", "uuid": "92c50bce-edf1-4ccc-9704-7b88e25e3925", "postContentEncoding": "NONE" }, { "headers": [], "method": "GET", "name": "pull request comments processor", "password": "...", "projectKey": "ST_USL", "proxySchema": "http", "repositorySlug": "oce_usl", "triggerIfCanMerge": "ALWAYS", "triggerIgnoreStateList": [], "triggers": [ "COMMENTED" ], "url": "http://sdt-usl2.vci.att.com:17723/jenkins/job/comment-processor/build?abc=xyz", "user": "m84796@sharedservices.att.com", "uuid": "fe44bb2b-94d7-43fa-a3f3-f3853162be8c", "postContentEncoding": "NONE" } ]
I also note that on the page where I edit my PRNs, it seems like entries in this list are being cloned without my doing anything. When I click on the dropdown right now, there is "New", then ONE "Pull Request Creation" (this REST output has two of them), then five "pull request comments processor" (same count as in REST output). There should only be two PRNs defined, "Pull Request Creation" and "pull request comments processor".
Ah, I see why there are two "Pull Request Creation" entries. This REST output is not project or repo specific. I have multiple repos with similar PRNs defined. That doesn't explain the multiple "pull request comments processor" entries.
I now have deleted all the "duplicate" comment-processor entries. The design of that form seems awkward to me. I've also refined the build job slightly, along with the URL in the PRN.
Here's the latest output from it:
[ { "headers": [], "method": "POST", "name": "Pull Request Creation", "password": "...", "projectKey": "ST_USL", "repositorySlug": "usl_monitor", "triggerIfCanMerge": "ALWAYS", "triggerIgnoreStateList": [], "triggers": [ "OPENED", "REOPENED", "UPDATED" ], "url": "http://sdt-usl2.vci.att.com:17723/jenkins/job/usl-monitor-build-pipeline/buildWithParameters?token=usl&cause=prn-create&JP_PullRequestTitle=${PULL_REQUEST_TITLE}&JP_CodeBranch=${PULL_REQUEST_FROM_BRANCH}&JP_PullRequestURL=${PULL_REQUEST_URL}", "user": "m84796@sharedservices.att.com", "uuid": "88329d8a-955f-4a7d-9985-9d02b231d926", "postContentEncoding": "NONE" }, { "headers": [], "method": "POST", "name": "Pull Request Creation", "password": "...", "projectKey": "ST_USL", "repositorySlug": "oce_usl", "triggerIfCanMerge": "ALWAYS", "triggerIgnoreStateList": [], "triggers": [ "OPENED", "REOPENED", "RESCOPED_FROM", "UPDATED" ], "url": "http://sdt-usl2.vci.att.com:17723/jenkins/job/unified-service-layer-build-pipeline/buildWithParameters?token=usl&cause=prn-create&JP_PullRequestTitle=${PULL_REQUEST_TITLE}&JP_CodeBranch=${PULL_REQUEST_FROM_BRANCH}&JP_PullRequestURL=${PULL_REQUEST_URL}", "user": "m84796@sharedservices.att.com", "uuid": "d26f0e24-17cf-42d1-abb2-9f36a4bc4445", "postContentEncoding": "NONE" }, { "headers": [], "method": "GET", "name": "pull request comments processor", "projectKey": "ST_USL", "proxySchema": "http", "repositorySlug": "oce_usl", "triggerIfCanMerge": "ALWAYS", "triggerIgnoreStateList": [], "triggers": [ "COMMENTED" ], "url": "http://sdt-usl2.vci.att.com:17723/jenkins/job/comment-processor/buildWithParameters?token=comment&PULL_REQUEST_ID=${PULL_REQUEST_ID}", "uuid": "aed2e876-d760-4e72-bce9-b61d56d17d3f", "postContentEncoding": "NONE" } ]
I modified the build job to define a single parameter "PULL_REQUEST_ID", and I defined a required token value of "comment".
Still nothing happens when I add a comment to a review.
It might be that it crashes because of one of the other notifcations triggered by comment. I would remove the one notifying https://requestb.in/11hgfpf1?${EVERYTHING_URL}
.
And also the logs are necessary in order to investigate this further.
Probably crossed our posts there. I did delete that one calling requestb.in, so it's only got the one going to my jenkins job. I will appeal to the one guy who deals with this (who works on the other side of the planet) to give me logs for these attempts.
One idea would be to:
Outstanding. That's a great shortcut to shorten the dev cycle on these PRN definitions. I got the button press (selecting from a dropdown, really) to fire the build, and I saw the PULL_REQUEST_ID value in the job's output. On the first try it gave me a 401, which made me realize that this instance of the PRN was missing the user/password credentials. I had set that before, but I apparently didn't realize that I was getting copies of this PRN definition with slightly different settings. I fixed that again and my button press fired the job, but then I realized I had to clear the "Filter string" and "Filter regexp" fields so that it would fire on just a comment add. Once I cleared those two fields, I added a comment to a PR, and it fired the job.
How can I configure it so that the PRN will fire on a button press for debugging and ALSO on the comment add? I had the "filter string" set to "${BUTTON_TRIGGER_TITLE}" and the "filter regexp" set to "Trigger Comment Processor" (my button title).
Nice! =)
If you check both comment and button events.
Set the filter string to ${PULL_REQUEST_ACTION} ${PULL_REQUEST_TITLE}
.
Set filter regexp to something like:
^BUTTON_TRIGGER DEBUGGING$|^COMMENTED.*
That should show buttons only if the PR has the title DEBUGGING.
When a comment is added, what variable tells me what user entered the comment?
That would be ${PULL_REQUEST_COMMENT_TEXT}
I'm confused. That's the text of the comment, not who sent it.
Ok. From the readme: "The ${PULL_REQUEST_USER...} contains information about the user who issued the event. Who commented it, who rejected it, who approved it..."
Ok. I couldn't tell from the name of that property what it really represented. Another issue: How do I get the comment id, so I can build the same url we get in emails ("/overview?commentId=999&action=view")? I don't see a "PULL_REQUEST_COMMENT_ID" variable in that list.
There is no variable for PULL_REQUEST_COMMENT_ID. And I don't consider it important enought to release for BBS 4.x. But I'll add it for 5.x. Atlassian does not make it easy to maintain several major versions.
A general comment about the documentation for the available variables: It needs to have more than just the example. It needs to say what it represents. For instance, what exactly is "PULL_REQUEST_PARTICIPANTS_EMAIL"? I'd like to get the list of all the people involved in the review, including the author, reviewers, and anyone else who's commented on the review. In my testing, this variable comes out empty.
I ended up just lumping the AUTHOR_EMAIL with the REVIEWERS_EMAIL, which will get the vast majority of cases, but I'm guessing the intent of "PARTICIPANTS_EMAIL" (since there is no statement I can find of what it's supposed to represent) is to get people who are neither of those (asked to look at a review without being a reviewer). The result from my testing, however, is an empty list.
Our enterprise BitBucket is version 4.9.0. I don't know what version of PRN plugin is in use. I'm not sure how to determine that.
I primarily use the PRN to spawn builds on creation of the PR and when new commits are pushed to the PR branch. I'm trying to utilize the COMMENTED event to implement automation for new comments in discussion threads. What I find is that my PRN simply doesn't fire when comments are made in a PR.
From https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/199 , it appears that with our older version of BitBucket, even if I could get this to fire, I wouldn't be able to do much with it. I'm just trying to understand the situation with this.