You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/actions-and-automations/setup-backend/create-update-entity/create-update-entity.md
+108-2Lines changed: 108 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,6 @@
1
+
import Tabs from "@theme/Tabs"
2
+
import TabItem from "@theme/TabItem"
3
+
1
4
# Create/update entity
2
5
3
6
In some cases, we don't want to run complex logic via a workflow or pipeline, but rather want our backend to simply create or update an entity in our software catalog.
@@ -33,15 +36,15 @@ To use this backend type, you will need to define the following fields:
33
36
| `team` | The team/s this entity will belong to. |
34
37
| `icon` | The icon of the entity. |
35
38
| `properties` | The properties of the entity, in `"key":"value"` pairs where the key is the property's identifier, and the value is its value. |
36
-
| `relations` | The relations of the entity, in `"key":"value"` pairs where the key is the relation's identifier, and the value is the related entity's identifier. |
39
+
| `relations` | The relations of the entity, in `"key":"value"` pairs where the key is the relation's identifier, and the value is the related entity's identifier (for single relations) or an array of identifiers (for "many" relations). |
37
40
38
41
### Use jq to map the entity
39
42
40
43
All fields in the `mapping` object can be mapped using `jq` expressions, by wrapping the value in double curly braces `{{ }}`.
41
44
42
45
For example, say we want to assign the initiator of the action to a new entity when it is created, we can take his email from the action run object and assign it to a property named `assignee`:
43
46
44
-
```json
47
+
```json showLineNumbers
45
48
{
46
49
"identifier": "someTaskEntity",
47
50
"title": "Some Task",
@@ -55,3 +58,106 @@ For example, say we want to assign the initiator of the action to a new entity w
55
58
:::tip Test your mapping
56
59
You can use the `Test JQ` button in the bottom-left corner to test your mapping against the action's schema.
57
60
:::
61
+
62
+
## Map entity relations
63
+
64
+
When creating or updating entities, you often need to establish relations with other entities. The mapping approach depends on whether you're dealing with single or multiple entity inputs.
For a single entity relation, map the entity identifier directly:
76
+
77
+
```json showLineNumbers
78
+
{
79
+
"identifier": "myServiceEntity",
80
+
"title": "My Service",
81
+
"properties": {},
82
+
"relations": {
83
+
"domain": "{{ .inputs.domain }}"
84
+
}
85
+
}
86
+
```
87
+
88
+
</TabItem>
89
+
90
+
<TabItemvalue="array">
91
+
92
+
When your action accepts [array entity inputs](/docs/actions-and-automations/create-self-service-experiences/setup-ui-for-action/user-inputs/entity.md#array), you need to extract the identifiers from the array using the `map(.identifier)` pattern:
When users select multiple entities from an [entity array input](/docs/actions-and-automations/create-self-service-experiences/setup-ui-for-action/user-inputs/entity.md#array), the input contains an array of entity objects. Each object includes both `identifier` and `title` properties, but relations can only reference entity identifiers.
107
+
:::
108
+
109
+
</TabItem>
110
+
111
+
<TabItemvalue="flexible">
112
+
113
+
For maximum flexibility, you can create a conditional mapping that handles both single entity and array entity inputs:
114
+
115
+
```json showLineNumbers
116
+
{
117
+
"identifier": "myProjectEntity",
118
+
"title": "My Project",
119
+
"properties": {},
120
+
"relations": {
121
+
"dependencies": "{{ .inputs.dependencies | if type == \"array\" then map(.identifier) else .identifier end }}"
122
+
}
123
+
}
124
+
```
125
+
126
+
This pattern automatically:
127
+
- Extracts identifiers from arrays when multiple entities are selected
128
+
- Uses the identifier directly when a single entity is selected
129
+
130
+
</TabItem>
131
+
132
+
</Tabs>
133
+
134
+
135
+
### Common use cases
136
+
137
+
Here are some typical scenarios for mapping array relations:
Relations can only reference entity **identifiers**, not titles. Even though entity objects contain both `identifier` and `title` properties, you must always use `.identifier` when mapping to relations.
Copy file name to clipboardExpand all lines: docs/api-reference/pages.mdx
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@
6
6
7
7
Port API's `pages` endpoints will undergo a structural change in the near future. The new structure will be more intuitive and easier to use.
8
8
9
+
Until the new structure is released, you can refer to the [Swagger API documentation](https://api.port.io/swagger/#Pages) for the available endpoints and their usage.
10
+
9
11
Currently, the `pages` endpoints allow you to:
10
12
11
13
-**Create**, **update**, **delete**, and **get** pages.
Copy file name to clipboardExpand all lines: docs/build-your-software-catalog/sync-data-to-catalog/git/azure-devops/mapping_extensions.md
+35-1Lines changed: 35 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,4 +45,38 @@ To do so, we will use the `file://` prefix with the path of the file to tell the
45
45
url: .remoteUrl
46
46
// highlight-next-line
47
47
readme: file://README.md
48
-
```
48
+
```
49
+
50
+
## Link pipelines to repositories via selector
51
+
You can configure your selector to include repository information in the pipeline entity mapping.
52
+
This allows you to create a direct relationship between a pipeline and its source repository.
53
+
54
+
```yaml showLineNumbers
55
+
- kind: pipeline
56
+
selector:
57
+
query: 'true'
58
+
# highlight-next-line
59
+
includeRepo: 'true'
60
+
port:
61
+
entity:
62
+
mappings:
63
+
identifier: .id | tostring
64
+
title: .name
65
+
blueprint: '"azureDevOpsPipeline"'
66
+
properties:
67
+
url: .url
68
+
revision: .revision
69
+
folder: .folder
70
+
relations:
71
+
project: .__projectId | gsub(" "; "")
72
+
repository: >-
73
+
if .__repository
74
+
then .__repository.project.name + "/" + .__repository.name | gsub(" "; "")
75
+
else null
76
+
end
77
+
```
78
+
:::tip Recommendation
79
+
Use this only when necessary, as including repository data requires an extra API call per pipeline, which increases the number of requests made and can impact your Azure DevOps API rate limits.
80
+
81
+
If you don’t require repo-level linkage, it’s more efficient to relate pipelines → projects instead.
0 commit comments