#92 Adding QA contact field support
Merged 4 years ago by sidpremkumar. Opened 4 years ago by sidpremkumar.
sidpremkumar/sync-to-jira qa-contact-field  into  develop

Fixing change status doc string
sidpremkumar • 4 years ago  
Adding QA contact field support
sidpremkumar • 4 years ago  
file modified
+4
@@ -58,6 +58,10 @@ 

  

  2. DEFAULT_SERVER - Mail server to be used

  

+ Custom Fields

+ -------------

+ Sync2Jira supports custom fields. You can pass them in as a parameter in your project ``custom-fields: {...}``.

+ 

  Development

  -----------

  

file modified
+18 -8
@@ -491,14 +491,13 @@ 

  

  def _change_status(client, downstream, status, issue):

      """

-     Change status of JIRA issue

-     Args:

-         client (jira.client.JIRA): JIRA client

-         downstream (jira.resources.Issue): JIRA issue object

-         status (str): Title of status to which issue should be move

-         issue (sync2jira.intermediary.Issue): Issue object

-     Returns:

-         Nothing

+     Change status of JIRA issue.

+ 

+ 

+     :param jira.client.JIRA client: JIRA client

+     :param jira.resources.Issue downstream: JIRA issue object

+     :param String status: Title of status to which issue should be move

+     :param sync2jira.intermediary.Issue issue: Issue object

      """

      transitions = client.transitions(downstream)

      id = ''
@@ -565,6 +564,17 @@ 

      log.info("   Creating issue.")

      downstream = client.create_issue(**kwargs)

  

+     # Add QA field if present

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

+         # Fetch all fields

+         all_fields = jira.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')})

+ 

      remote_link = dict(url=issue.url, title=remote_link_title)

      _attach_link(client, downstream, remote_link)

  

Cosmetic: erroneous whitespace?

Custom field id may be different in other versions, for example in testing stage JIRA this field has id customfield_13200, so, please, use request for finding right id. https://confluence.atlassian.com/jirakb/how-to-find-id-for-custom-field-s-744522503.html

I've checked the prod JIRA and it uses customfield_12811. If you inspect element on a JIRA issue, on QA contact you can see the value of the custom field.

Yes, but again, different JIRA use different ids, stage JIRA use id customfield_13200, so it will be better to not hard code id.

Hmm but if we don't hard code it in, then we don't need this PR and if people want to add custom fields they can use the custom_fields array that is already supported? What were you thinking instead?

My point is, this field is used a lot, so it will be better to add support in configuration not by id, but by name. In that case it's not needed to looking for id and this will improve user experience.

That was what I was thinking as well. But if we want that; we will need to hard code the custom field ID into the program, no?

That was what I was thinking as well. But if we want that; we will need to hard code the custom field ID into the program, no?

No, we can find id by name. API can return list of all fields with their ids, https://confluence.atlassian.com/jirakb/how-to-find-id-for-custom-field-s-744522503.html

Ah I see what youre refering too. I've tried that, only problem is it returns a list of custom fields (i.e. {customfield_1, customfield_2...... etc). So there is no real way to check the name vs the ID.

rebased onto b6194d67da6f053632a0776e7615392326505f00

4 years ago

rebased onto fe28ca29b1782e994f751913c5c207b06c4021d9

4 years ago

rebased onto 7d0e9e2

4 years ago

Pull-Request has been merged by sidpremkumar

4 years ago
Metadata