|
| 1 | +--- |
| 2 | +displayed_sidebar: null |
| 3 | +description: Automatically map Jira users to their Port user accounts for seamless integration |
| 4 | +--- |
| 5 | + |
| 6 | +# Map Jira users to Port user accounts |
| 7 | + |
| 8 | +This guide demonstrates how to automatically map Jira users to existing Port user accounts based on email addresses. |
| 9 | + |
| 10 | +Once implemented, users will be able to: |
| 11 | +- Maintain a complete inventory of all Jira users in your organization within Port. |
| 12 | +- Automatically link Jira users to their corresponding Port user accounts for seamless integration. |
| 13 | +- Provide visibility into which Jira users have Port accounts and which ones do not. |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +This guide assumes the following: |
| 18 | +- You have a Port account and have completed the [onboarding process](https://docs.port.io/getting-started/overview). |
| 19 | +- You have [Port's Jira integration](/build-your-software-catalog/sync-data-to-catalog/project-management/jira/) installed and configured. |
| 20 | +- You have permissions to create automations in Port. |
| 21 | + |
| 22 | + |
| 23 | +## Set up data model |
| 24 | + |
| 25 | +The relation between Jira users and Port users is created automatically when we install the [Jira integration](/build-your-software-catalog/sync-data-to-catalog/project-management/jira/). If you haven't installed it yet, please do so first. |
| 26 | + |
| 27 | +<h3>Add mirror properties to the Port User blueprint</h3> |
| 28 | + |
| 29 | +1. Go to the [data model](https://app.getport.io/settings/data-model) page of your portal. |
| 30 | + |
| 31 | +2. Find the `User` blueprint and click on it. |
| 32 | + |
| 33 | +3. Click on the `Edit JSON` button in the top right corner. |
| 34 | + |
| 35 | +4. Add the following mirror property to the `mirrorProperties` object to display the Jira display name: |
| 36 | + |
| 37 | + <details> |
| 38 | + <summary><b>Port User blueprint mirror property (Click to expand)</b></summary> |
| 39 | + |
| 40 | + ```json showLineNumbers |
| 41 | + "mirrorProperties": { |
| 42 | + "jira_display_name": { |
| 43 | + "title": "Jira display name", |
| 44 | + "path": "jiraUser.displayName" |
| 45 | + } |
| 46 | + } |
| 47 | + ``` |
| 48 | + |
| 49 | + </details> |
| 50 | + |
| 51 | +5. Click on `Save` to update the blueprint. |
| 52 | + |
| 53 | +:::info Additional mirror properties |
| 54 | +You can add more mirror properties to display other Jira user attributes like timezone (`jiraUser.timeZone`), account type (`jiraUser.accountType`), or any other property from the Jira User blueprint that would be useful for your organization. |
| 55 | +::: |
| 56 | + |
| 57 | + |
| 58 | +## Update Jira integration mapping |
| 59 | + |
| 60 | +1. Go to the [data sources](https://app.getport.io/settings/data-sources) page. |
| 61 | + |
| 62 | +2. Find your Jira integration and click on it. |
| 63 | + |
| 64 | +3. In the mapping configuration, add a new mapping for Port User entities to establish the relation with Jira users. |
| 65 | + |
| 66 | + <details> |
| 67 | + <summary><b>Updated Jira integration mapping (Click to expand)</b></summary> |
| 68 | + |
| 69 | + ```yaml showLineNumbers |
| 70 | + # Keep existing jiraUser mapping |
| 71 | + - kind: user |
| 72 | + selector: |
| 73 | + query: 'true' |
| 74 | + port: |
| 75 | + entity: |
| 76 | + mappings: |
| 77 | + identifier: .accountId |
| 78 | + title: .displayName |
| 79 | + blueprint: '"jiraUser"' |
| 80 | + properties: |
| 81 | + emailAddress: .emailAddress |
| 82 | + active: .active |
| 83 | + accountType: .accountType |
| 84 | + timeZone: .timeZone |
| 85 | + locale: .locale |
| 86 | + avatarUrl: .avatarUrls["48x48"] |
| 87 | + |
| 88 | + # Add new mapping for Port Users with relation to Jira users |
| 89 | + // highlight-start |
| 90 | + - kind: user |
| 91 | + selector: |
| 92 | + query: '.emailAddress != null' |
| 93 | + port: |
| 94 | + entity: |
| 95 | + mappings: |
| 96 | + identifier: .emailAddress |
| 97 | + blueprint: '"_user"' |
| 98 | + relations: |
| 99 | + jiraUser: .accountId |
| 100 | + // highlight-end |
| 101 | + ``` |
| 102 | + </details> |
| 103 | + |
| 104 | +4. Click on `Save & Resync` to apply the changes. |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | +## Set up automations |
| 109 | + |
| 110 | +To ensure new Port users are automatically mapped to their corresponding Jira user accounts when a new Port user is created, we'll create an automation that triggers when a new Port user is created. |
| 111 | + |
| 112 | +Follow the steps below to create the automation: |
| 113 | + |
| 114 | +1. Go to the [automations](https://app.getport.io/settings/automations) page of your portal. |
| 115 | + |
| 116 | +2. Click on `+ Automation`. |
| 117 | + |
| 118 | +3. Click on the `Edit JSON` button in the top right corner. |
| 119 | + |
| 120 | +4. Copy and paste the following automation configuration: |
| 121 | + |
| 122 | + <details> |
| 123 | + <summary><b>Automation to sync Port users to Jira user account (Click to expand)</b></summary> |
| 124 | + |
| 125 | + ```json showLineNumbers |
| 126 | + { |
| 127 | + "identifier": "sync_port_user_for_jira_user", |
| 128 | + "title": "Sync Port User for Jira User", |
| 129 | + "description": "Automatically maps Port users to their corresponding Jira user accounts", |
| 130 | + "icon": "Jira", |
| 131 | + "trigger": { |
| 132 | + "type": "automation", |
| 133 | + "event": { |
| 134 | + "type": "ENTITY_CREATED", |
| 135 | + "blueprintIdentifier": "_user" |
| 136 | + }, |
| 137 | + "condition": { |
| 138 | + "type": "JQ", |
| 139 | + "expressions": [], |
| 140 | + "combinator": "and" |
| 141 | + } |
| 142 | + }, |
| 143 | + "invocationMethod": { |
| 144 | + "type": "WEBHOOK", |
| 145 | + "url": "https://api.getport.io/v1/entities/_user/{{ .event.diff.after.identifier }}/relations", |
| 146 | + "agent": false, |
| 147 | + "synchronized": true, |
| 148 | + "method": "POST", |
| 149 | + "headers": { |
| 150 | + "Content-Type": "application/json" |
| 151 | + }, |
| 152 | + "body": { |
| 153 | + "relations": { |
| 154 | + "jiraUser": { |
| 155 | + "combinator": "and", |
| 156 | + "rules": [ |
| 157 | + { |
| 158 | + "property": "$identifier", |
| 159 | + "operator": "=", |
| 160 | + "value": "{{ .event.diff.after.identifier }}" |
| 161 | + } |
| 162 | + ] |
| 163 | + } |
| 164 | + } |
| 165 | + } |
| 166 | + }, |
| 167 | + "publish": true |
| 168 | + } |
| 169 | + ``` |
| 170 | + |
| 171 | + </details> |
| 172 | + |
| 173 | +5. Click `Save` to create the automation. |
| 174 | + |
| 175 | + |
| 176 | +## Let's test it |
| 177 | + |
| 178 | +1. Go to your [software catalog](https://app.getport.io/catalog) page. |
| 179 | + |
| 180 | +2. Search for a Jira user entity. |
| 181 | + |
| 182 | +3. Verify that the user has a relationship with the corresponding Port user account. |
| 183 | + |
| 184 | +4. Check that the relationship is established automatically for new Jira users. |
| 185 | + |
0 commit comments