Upsource Webhooks and JIRA - jira

I am working on automating the code review process in my team.
My objectives are:
When a review is created, assign it to two random developers
Automatically update the JIRA item, and assign them to the developers who were assigned as reviewers in Upsource
I was able to achieve objective #1 using Upsource Custom Workflows.
For the second objective, I have tried looking at Upsource Webhooks and JIRA Cloud REST API, but I fail to see how to assign a JIRA item from Upsource. JIRA's API specifies that in order to assign an item using REST, we need to create PUT request to this method:
PUT /rest/api/2/issue/{issueIdOrKey}/assignee
How can I create a PUT request from Upsource Webhooks?
How can I extract the {issueIDOrKey} from the originating Upsource review?

How can I create a PUT request from Upsource Webhooks?
Upsource webhooks send only POST requests at the moment. But I don't see how this limitation is blocking your task, because as I understand there has to be a service that'll translate Upsource payload to JIRA payload. That service should make a PUT request.
How can I extract the {issueIDOrKey} from the originating Upsource review?
Upsource provides an API for this. getReviewDetails method allows to get a list of issues associated with a given review (see this message spec).

Related

How to forward an email and change the subject using the Microsoft Graph api

recently I ran into a problem where I was using python imap to automate outlook tasks, but microsft changed basic auth to Oauth now, and I have not being able to authenticate ever since, I get an error
imaplib.error: AUTHENTICATE failed.
So I started working with the Microsoft graph API, in which I can get the information that I need but once I need to forward an email I can't setup a custom subject, I can just add a comment and toRecepient custom arguments.
https://learn.microsoft.com/en-us/graph/api/message-forward?view=graph-rest-1.0&tabs=http
any advice here ?
If you use the Create-Forward endpoint https://learn.microsoft.com/en-us/graph/api/message-createforward that will create a draft message of the forward which you can then patch any message property you want to update and then send.
The one thing they don't mention in the documentation is you should set the Prefer: outlook.timezone header to make sure the dates in you response are set the local time of the responder.

In AzureDevOps Server (on prem) how do I get the timestamp when I last looked at a Pull Request?

I'm using the Microsoft.VisualStudio.Services.Client library (added via NuGet) to connect to my on-prem Azure Dev Ops server and query various bits of information regarding pull requests. I'd like to make a little notification application that can alert me if someone has replied to a comment I made on a pull request. The trick is that I only want to see the notification if I haven't already looked at it.
I know that the system knows when I last looked at the pull request because it decorates pull requests with new content (comments, new code, etc.) with a little dot and when I open a pull request, it tells me that there are new comments since I visited last and tells me how long ago I looked at it.
How do I get access to the date that I opened the pull request in the web via the client libraries or REST? In other words, how would my app know that I have or haven't looked at new comments via the web page?
I did not find such an api that can retrieve the timestamp the last time you looked at the PR.
There is lastUpdatedDate you can use to track the comments that were checked. So as a workaround you can save the lastUpdatedDate to a file in your code, and compare this value everytime when you call api. Then you will get the latest updated comments.
However, PR comments notification can also be configured from azure devops. You can go to your user profile on the top right corner and select notifications to enable the notification for A comment is left on a pull request.
For more information about Azure devops notification, you can check this document.

Getting change id's of depending changes from gerrit rest or ssh api?

Gerrit allows associated external changes into a single change request via "Depends-On" on the commit message. However, by the looks of it, rest api does not expose these dependencies.
I can ofcourse get the commit message and then parse it, and then get change request for this external change.
Anyone know if there would be a bit more streamlined option to archive the same ?
You can get the related changes using REST API:
'GET /changes/{change-id}/revisions/{revision-id}/related'
Retrieves related changes of a revision. Related changes are changes
that either depend on, or are dependencies of the revision.
Request GET
/changes/gerrit~master~I5e4fc08ce34d33c090c9e0bf320de1b17309f774/revisions/b1cb4caa6be46d12b94c25aa68aebabcbb3f53fe/related
HTTP/1.0
See more info in the Gerrit documentation here

Jenkins Pipeline, retrieve information from JIRA ticket

I was just wondering if there was anyway to retrieve information from a Jira ticket and assign it to a variable in Jenkins.
So (just an example) - I'd like to save label from a ticket as $Jira_Label
You can send a REST request to JIRA and retrieve the information, like the label, of a specified issue.
Here there is the list of the available requests you can send.

Asana Webhooks API

So I have implemented the Asana Webhooks API as described in their documents. I can pass it a project ID and request a new webhook be created. The API successfully sends a authentication request to my application which returns the Security header as described in the Docs. Asana then returns the expected success response, outlining the newly created Webhooks unique ID.
Now if i take this ID and then query the Asana API to show me all configured webhook's on either the parent Workspace or the project resource directly it returns an empty data JSON Object or reports the resource doesn't exist, suggesting the Webhook Ive just created wasn't actually created, despite giving me the expected success response.
Also If I then make a change to a project it doesn't fire the webhook and I don't receive any events on my application.
Strangely everything was working on Friday but today (Monday) I'm experiencing these issues.
Any pointers would be good, Ive been working as the Docs suggest in terms of my request structure and am authenticating using a PAT, Ive even tried a newly created token.
Thanks,
Our webhooks use the handshake mechanism to make sure that it's possible to call you back, but there's always the possibility that subsequent requests can fail. Additionally (although we don't document this very well - there's an opportunity for us) we should immediately try to deliver a (probably) empty event after the handshake (it looks like {"events":[]}. This is kind of like a "second callback" that contains anything that has changed since you created the webhook.
If this fails - or if any subsequent request fails often enough - the webhook will get trashed. "Failure" in this context means returns HTTP response codes other that 200 or 204.
As for why you're having trouble querying the webhook itself, I wasn't able to repro the issue, so we'd have to dive deeper. It should be fine if you:
Specify the workspace
Optionally specify the resource
I tested this out, and it seemed fine. You also might want to directly query the webhook by id with the /webhooks/:id endpoint - note to use the id of the webhook returned by create, and not the id in the resource field.
If you created the webhook (specifically, your PAT or OAuth app was the one making the create request) you should see the information just fine. If you can get the webhook by id, you should see last_failure_at and last_failure_content fields which would tell you why the webhook was unable to make the delivery.
Finally, if you would like to contact us at api-support#asana.com and let them know more details (for instance, the ID of the webhook you're trying to look at) we can look at those fields from our side to see if we can identify what's going on.

Resources