#117 Add epic link support
Merged 4 years ago by sidpremkumar. Opened 4 years ago by sidpremkumar.
sidpremkumar/sync-to-jira epic-link-support  into  develop

Add docs for qa-contact and epic-link
sidpremkumar • 4 years ago  
Add epic link support
sidpremkumar • 4 years ago  
file modified
+2 -1
@@ -28,7 +28,8 @@ 

      'Demo_project': {'project': 'PROJECT', 'component': 'COMP',

                       'updates': [...], 'owner': 'project_owner_username',

                       'default_status': 'start_status_for_issue'

-                      'labels: ['tag1'..]},

+                      'labels: ['tag1'..], 'qa-contact': 'some@some.com',

+                      'epic-link': 'FACTORY-1234'},

  

  

  The following can be added to the updates array to specify what to sync with downstream

file modified
+14 -1
@@ -70,7 +70,20 @@ 

              },

          },

  

- * You can add your projects here. The 'project' field is associated with downstream JIRA projects, and 'component' with downstream components. 

+ * You can add the following to your project configuration:

+ 

+     * :code:`'project'`

+         * Downstream project to sync with

+     * :code:`'component'`

+         * Downstream component to sync with

+     * :code:`'owner'`

+         * Optional (Recommended): Alerts the owner of an issue if there are duplicate issues present

+     * :code:`'qa-contact'`

+         * Optional: Automatically add a QA contact field when issues are created

+     * :code:`'epic-link'`

+         * Optional: Pass the downstream key to automatically create an epic-link when issues are created

+ 

+ * You can add your projects here. The 'project' field is associated with downstream JIRA projects, and 'component' with downstream components

    You can add the following to the updates array: 

      

      * :code:`'comments'` 

file modified
+13 -6
@@ -596,16 +596,23 @@ 

      log.info("   Creating issue.")

      downstream = client.create_issue(**kwargs)

  

-     # Add QA field if present

-     if issue.downstream.get('qa-contact', None):

+     # Add Epic link or QA field if present

+     if issue.downstream.get('epic-link', None) or \

+             issue.downstream.get('qa-contact', None):

          # Fetch all fields

          all_fields = client.fields()

          # Make a map from field name -> field id

          name_map = {field['name']: field['id'] for field in all_fields}

-         # Try to get and update the custom field

-         custom_field = name_map.get('QA Contact', None)

-         if custom_field:

-             downstream.update({custom_field: issue.downstream.get('qa-contact')})

+         if issue.downstream.get('epic-link', None):

+             # Try to get and update the custom field

+             custom_field = name_map.get('Epic Link', None)

+             if custom_field:

+                 downstream.update({custom_field: issue.downstream.get('epic-link')})

+         if issue.downstream.get('qa-contact', None):

+             # Try to get and update the custom field

+             custom_field = name_map.get('QA Contact', None)

+             if custom_field:

+                 downstream.update({custom_field: issue.downstream.get('qa-contact')})

  

      # Add upstream issue ID in comment if required

      if 'upstream_id' in issue.downstream.get('updates', []):

file modified
+2 -2
@@ -163,7 +163,7 @@ 

              try:

                  d.sync_with_jira(issue, config)

              except Exception:

-                 log.error("Failed on %r", issue)

+                 log.error("   Failed on %r", issue)

                  raise

      log.info("   Done with pagure initialization.")

  
@@ -172,7 +172,7 @@ 

              try:

                  d.sync_with_jira(issue, config)

              except Exception:

-                 log.error("Failed on %r", issue)

+                 log.error("   Failed on %r", issue)

                  raise

      log.info("   Done with github initialization.")

  

@@ -48,6 +48,8 @@ 

              'project': 'mock_project',

              'custom_fields': {'somecustumfield': 'somecustumvalue'},

              'type': 'Fix',

+             'qa-contact': 'dummy@dummy.com',

+             'epic-link': 'DUMMY-1234',

              'updates': [

                  'comments',

                  {'tags': {'overwrite': False}},
@@ -334,6 +336,10 @@ 

          """

          # Set up return values

          mock_client.create_issue.return_value = self.mock_downstream

+         mock_client.fields.return_value = [

+             {'name': 'Epic Link', 'id': 'customfield_1'},

+             {'name': 'QA Contact', 'id': 'customfield_2'},

+         ]

  

          # Call the function

          response = d._create_jira_issue(
@@ -363,6 +369,8 @@ 

              self.mock_issue,

              mock_client

          )

+         self.mock_downstream.update.assert_any_call({'customfield_1': 'DUMMY-1234'})

+         self.mock_downstream.update.assert_any_call({'customfield_2': 'dummy@dummy.com'})

          self.assertEqual(response, self.mock_downstream)

  

      @mock.patch(PATH + '_update_jira_issue')

Add support to automatically create an epic link

  • Update docs & tests accordingly

rebased onto a40d207

4 years ago

1 new commit added

  • Add docs for qa-contact and epic-link
4 years ago

:+1: assuming tests pass.

2 new commits added

  • Add docs for qa-contact and epic-link
  • Add epic link support
4 years ago

Pull-Request has been merged by sidpremkumar

4 years ago