Forums

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

how to automatically create a comment in github when comment added to issue in jira using automation

Siva Nagendra January 3, 2023

.

3 answers

2 votes
Jimmy Seddon
Community Champion
January 3, 2023

Hi @Siva Nagendra,

Welcome to the Community!

What exactly are you wanting to make a comment on in Github based on a comment being made in Jira?

For the most part I don't believe Jira Automations directly support adding comments to things like Pull Requests.  However, you can send a web request through an automation rule if there is an API on the Github side that would be able to receive and perform the action you want.

I hope that helps!

Siva Nagendra January 7, 2023

Thank you for responding 

Happy new year@Jimmy Seddon

 

>What exactly are you wanting to make a comment on in Github based on a comment being made in Jira?

 

I have built an automation rule to create an issue in GitHub repository automatically when an issue is created in Jira(JSM) using GitHub REST API.

In the same way when an issue is commented in Jira then automatically the comment should be added to issue in GitHub.This is the usecase I wanted to achieve.

Jimmy Seddon
Community Champion
January 9, 2023

I don't think a Jira Automation rule is going to achieve what you want.  I think you might have more success triggering a webhook and using that to call your automation script.

Like # people like this
Siva Nagendra January 24, 2023

Hii @Jimmy Seddon  @Diana_Architect_ZigiWave  

 

Thank you for your suggestions. I have already achieved the outcome. 

 

The process to Integrate Jira Service Management with

using GitHub REST API

  • An issue is created automatically in GitHub Repository when an issue is created in Jira i.e JSM.
  • A comment should be created automatically in GitHub Issue when commented on the Jira issue.

The following are the major steps.

  • Create a Custom Number field in the JSM project to store the number from the webhookResponse body i.e issue number which is created in GitHub. - Step1
  • Create an Automation Rule to create an issue automatically in GitHub when created in Jira - Step2
  • Create an Automation Rule to create a comment and add to the appropriate issue in GitHub when created in Jira. - Step3

- to create API key.

Step - 1: Create a Custom Number field in the JSM project to store the number from the webhookResponse body i.e issue number which is created in GitHub.

  • Login to the Jira portal and select the JSM project.
  • Navigate to the project settings option and look for the Fields option.
  • Select the Fields option and click on the edit option(pencil symbol) which is available on the top-left side.
  • Now select the custom Field option on the left side of the screen.
  • Then you find a Create custom field option on the top-right and some custom fields are displayed.
  • Now search for the Number field option in the search bar by searching with the word Number.
  • Select the Number field and give a name and description to the Number field.
  • Now come back to the custom fields and all the fields will be displayed there.
    • Search for the number field that you have created before and the number field will be displayed.
    • You will find 3 dots in the left-middle of the screen and click on the 3 dots.
    • Navigate to the associate screen option when clicking on the 3 dots.
    • Now select all screens and scroll down to the bottom and click on update.
  • Now check the fields of the issue, whether the number field is created or not.

Note: Note down the Number custom field ID which will be used in further steps

  • Follow the below link to get a Custom field ID.

https://confluence.atlassian.com/jirakb/how-to-find-id-for-custom-field-s-744522503.html

Step - 2: Create an Automation Rule to create an issue automatically in GitHub when created in Jira

  • Navigate to the Automation section in Jira Service Management to create an Automation Rule.

  • Steps to create Automation Rule

    • Click on Create Rule.
    • Select trigger as Issue created and save.
    • Then select the New Action
    • Search for Send web request component in the search bar and configure the Send web request component. The following the configuration steps
      • Paste the GitHub Repository url in the Web request URL and it should be in the format ****[https://api.github.com/repos/OWNER/REPO/issues](<https://api.github.com/repos/OWNER/REPO/issues>) \\

      • Add the following Headers information.

        • Authorization - Bearer <TOKEN>
        • Accept - application/vnd.github+json
        • X-GitHub-Api-Version - 2022-11-28
      • Select the HTTP method as POST.

      • Select the custom data option in the Web request body and paste the following information in Custom data.

        { "title": "{{issue.key}}({{issue.Organizations}}){{issue.summary.jsonEncode}}", "body": "", "labels": [{{issue.labels.name}}] }

        Note: Atlassian ticket link should be changed accordingly.

      • Toggle the below two options of wait for response. These responses can be used for further automation components.

    • Now add one more action to the automation rule which is log action.
      • Give the {{webhookResponse.body.number}} in the log message and save the action.
      • Log action helps in debugging purposes and logs the value of {{webhookResponse.body.number}} in the Audit log.
    • Search for another action which is Create variable and add to the automation after the Audit log.
      • Name a variable name in the Variable name field.
      • Note the smart value as {{webhookResponse.body.number}} and save the Create Variable action.
    • Now add the edit issue action to the automation rule.
      • Select the Choose fields to set.. and select the number field which is created in step-1 to store the number from the variable which is created in the previous step(create variable).
      • Now paste the variable name in the field.
        • Eg: {{githubnumber}}
      • Add the Log Action to the automation rule to webhook response status in the Audit log.
        • Add the Log message with {{webhookResponse.status}} and save the action.
    • Now save the automation and test the scenario.

    Step - 3: Create an Automation Rule to create a comment and add to the appropriate issue in GitHub when created in Jira.

    • Navigate to the Automation section in Jira Service Management to create an Automation Rule.
    • Steps to create Automation Rule
      • Click on Create Rule.
      • Select trigger as Issue commented and save.
      • Select a condition component and add an if/else block.
        • Click on Add conditions and select Advanced compare condition.
        • Add the below details to the Advanced compare condition.
          • First value as {{comment.internal}}
          • condition as Equals
          • Second value as True and save the condition
        • Then select the New Action
        • Search for Send web request component in the search bar and configure the Send web request component. The following the configuration steps
          • Paste the GitHub Repository url in the Web request URL and it should be in the format ****[https://api.github.com/repos/OWNER/REPO/](<https://api.github.com/repos/OWNER/REPO/issues>)issues/{{issue.customfield_10073}}/comment

            • Note: appropriate Custom field ID should be added to the above URL
          • Add the following Headers information.

            • Authorization - Bearer <TOKEN>
            • Accept - application/vnd.github+json
            • X-GitHub-Api-Version - 2022-11-28
          • Select the HTTP method as POST.

          • Select the custom data option in the Web request body and paste the following information in Custom data.

            { "body": "<b> Internal comment </b> \\n\\n\\n {{comment.body.jsonEncode}}" }

          • Toggle the below two options of wait for response. These responses can be used for further automation components.

      • Click on the else block and add the condition.
        • Click on Add conditions and select Advanced compare condition.
        • Add the below details to the Advanced compare condition.
          • First value as {{comment.internal}}
          • condition as Equals
          • Second value as false and save the condition
        • Then select the New Action
        • Search for Send web request component in the search bar and configure the Send web request component. The following the configuration steps
          • Paste the GitHub Repository url in the Web request URL and it should be in the format ****[https://api.github.com/repos/OWNER/REPO/](<https://api.github.com/repos/OWNER/REPO/issues>)issues/{{issue.customfield_10073}}/comment

            • Note: appropriate Custom field ID should be added to the above URL
          • Add the following Headers information.

            • Authorization - Bearer <TOKEN>
            • Accept - application/vnd.github+json
            • X-GitHub-Api-Version - 2022-11-28
          • Select the HTTP method as POST.

          • Select the custom data option in the Web request body and paste the following information in Custom data.

            { "body": "<b> Update from the Customer </b> \\n\\n\\n {{comment.body.jsonEncode}}" }

          • Toggle the below two options of wait for response. These responses can be used for further automation components.

      • Now save the automation and test the scenario.

 

 

Hope this will be helpful for you. 

 

Thank you Atlassian community

Regards,

Siva

Like # people like this
1 vote
Dhiren Notani_Exalate_
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.
July 31, 2023

Hi @Siva Nagendra ,

I am Dhiren from the Exalate Team.

I would recommend you to try out Exalate

It is one-of-a-kind decentralized and fully bidirectional integration solution which can help you in syncing Jira Issues with GitHub Issues bidirectionally.

You can sync all the fields from GitHub Issues like Subject, Desc, Comments, Status, Labels, and even Assignee.

You can even automate the process of syncing tickets by using triggers.

Do let me know if you have any questions or would like to know more about the product.

Thanks, Dhiren

0 votes
Diana_Architect_ZigiWave
Atlassian Partner
January 24, 2023

@Siva Nagendra hi! There 3rd party tools that can help you achieve that. If you're open to the idea of exploring them as an option - feel free to check out ZigiOps, here at the atlassian marketplace. It's a fully no-code integration tool for bi-directional connection. Can be customized to fit various use cases and does not store any of your data. It can help with the jira github integration. If you want to know more - feel free to book a demo slot. It's free and non-binding.

Regards, Diana (ZigiOps team)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events