Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to automate update and close jira tickets with Azure DevOps

Richard Heijder
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!
July 23, 2024

Hi,

 

How can we use the API from the atlassian suite (jira) to automate Azure Pipelines when doing a pull request.

 

We can use JiraPS in Azure DevOps Pipelines but it keeps failing.

Script example:

 

 

taskPowerShell@2
  displayName'jira powershell'
  inputs:
    targetType'inline'
    script: |
      # Write your PowerShell commands here.
      Install-Module -Name JiraPS -Scope CurrentUser -Force -Verbose
      Import-Module -Name JiraPS -Force -Verbose
      Set-JiraConfigServer 'https://anwb.atlassian.net'
      New-JiraSession -Credential "rheijder@anwb.nl"
#      Connect-JiraServer -ServerUrl "https://anwb.atlassian.net" -Username "rheijder@anwb.nl" -Token $(token)
#      Get-Help about_JiraPS
#      Import-Module -Name JiraPS -Verbose
#      set-jiraissue -Issue "cpe-612" -AddComment "blahviadevops"
Anyone suggestions?
Regards,
Richard

1 answer

0 votes
John Price
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 5, 2024

I don't have access to ADO to test at the moment, but here's one way that avoids fooling with scripting & 3rd party libraries:

1) On the Jira side, set up a Jira Automation rule at the project or global level. Use 

When: Incoming Webhook
Then: Add Comment To Issue 

with smart values something like:

Pull request [{{webhookData.pullRequest.title}}]({{webhookData.pullRequest.url}}) has 
been created in Azure DevOps.

and copy the generated webhook URL to the clipboard.

2) On the ADO side, set up a Service Hook with event "pull request created" and paste the URL you copied from the Jira side.

You just need to decide where the issue key will be in ADO (branch name, PR title, whatever) and configured the Jira side "When" to collect the issue key(s) as needed from the payload: 

jira webhook incoming.png

 

 

John Price
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 5, 2024

Also: you can obviously close issues or take other actions too. And you may want to add the free https://marketplace.atlassian.com/apps/1232793/azure-devops-for-jira-official?hosting=cloud&tab=overview  app to make your integration tighter.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events