Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira to Cherwell communication when Jira Issue marked as DONE

Jan_Treger March 23, 2020

Hello all

We have recently introduced Cherwell to Jira integration so the service desk can create Issues and if there is a need for Development tasks. There is a "button" in Cherwell called "Send to Jira" which will create Issue in Jira. 

This all works fine...

What I'm trying to automate now is the process when the Issue in Jira is solved and backward update of the Cherwell ticket.

Is Jira able to send Rest API call to Cherwell when the Issue is marked as DONE to update the status in Cherwell?

Thank you very much

4 answers

0 votes
Suresh Sakhare
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 26, 2024

# Variables
$cherwellBaseUri = "https://your-cherwell-instance.com/CherwellAPI"
$cherwellUsername = "cherwellUsername"
$cherwellPassword = "cherwellPassword"
$cherwellIncidentId = "12345"

$jireBaseUri = "https://your-jira-instance.com/rest/api/2"
$jiraUsername = "jiraUsername"
$jiraPassword = "jiraPassword"
$jiraIssueKey = "PROJECT-123"

# Function to get Cherwell OAuth token
function Get-CherwellOAuthToken {
$authHeader = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$cherwellUsername:$cherwellPassword"))
$response = Invoke-RestMethod -Method Post -Uri "$cherwellBaseUri/token" -Headers @{Authorization = $authHeader} -ContentType "application/x-www-form-urlencoded" -Body "grant_type=password"
return $response.access_token
}

# Function to download attachment from Cherwell
function Download-CherwellAttachment {
param (
[string]$incidentId,
[string]$accessToken
)
$headers = @{ Authorization = "Bearer $accessToken" }
$attachments = Invoke-RestMethod -Method Get -Uri "$cherwellBaseUri/api/V1/getbusinessobjectattachments/busObId/$incidentId" -Headers $headers

foreach ($attachment in $attachments.attachments) {
$fileName = $attachment.fileName
$fileUri = "$cherwellBaseUri/api/V1/getbusinessobjectattachment/$attachment.attachmentId"
Invoke-RestMethod -Method Get -Uri $fileUri -Headers $headers -OutFile $fileName
return $fileName
}
}

# Function to upload attachment to Jira
function Upload-JiraAttachment {
param (
[string]$fileName
)
$authHeader = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$jiraUsername:$jiraPassword"))
$headers = @{
Authorization = $authHeader
"X-Atlassian-Token" = "no-check"
}
$form = @{
file = Get-Item $fileName
}
Invoke-RestMethod -Method Post -Uri "$jireBaseUri/issue/$jiraIssueKey/attachments" -Headers $headers -ContentType "multipart/form-data" -InFile $fileName
}

# Main script execution
try {
# Get Cherwell OAuth token
$cherwellToken = Get-CherwellOAuthToken

# Download attachment from Cherwell
$downloadedFileName = Download-CherwellAttachment -incidentId $cherwellIncidentId -accessToken $cherwellToken

# Upload attachment to Jira
Upload-JiraAttachment -fileName $downloadedFileName

Write-Output "Attachment successfully copied from Cherwell to Jira."
} catch {
Write-Output "An error occurred: $_"
}

0 votes
Eric Smith April 7, 2021

Hey guys,

You can check out this tool https://marketplace.atlassian.com/apps/1224485/zigiops-integrate-jira-with-cherwell?hosting=cloud&tab=overview. 

We are using it for systems integrations and its working quite well. 

Hope this helps!

 

Cheers,

Eric

0 votes
Srinath Reddy Pinappu July 21, 2020

Could you please share some inputs how integrate Cherwell with Jira ?

0 votes
Deepika Jesta
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 16, 2020

Can we please get your help to implement below

We have recently introduced Cherwell to Jira integration so the service desk can create Issues and if there is a need for Development tasks. There is a "button" in Cherwell called "Send to Jira" which will create Issue in Jira. 

I appreciate your help with this.

Suggest an answer

Log in or Sign up to answer