示例
映射项目、文件内容和合并请求
在下面的示例中,您将把 GitLab 项目、其 README.md 文件内容和合并请求引用到 Port,您可以使用以下 Port 蓝图定义和集成配置:
Repository blueprint
{
"identifier": "gitlabRepository",
"title": "Repository",
"icon": "Microservice",
"schema": {
"properties": {
"url": {
"title": "URL",
"type": "string",
"format": "url"
},
"readme": {
"title": "README",
"type": "string",
"format": "markdown"
},
"description": {
"title": "Description",
"type": "string"
},
"language": {
"title": "Language",
"type": "string"
},
"namespace": {
"title": "Namespace",
"type": "string"
},
"fullPath": {
"title": "Full Path",
"type": "string"
},
"defaultBranch": {
"title": "Default Branch",
"type": "string"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {}
}
Merge request blueprint
{
"identifier": "gitlabMergeRequest",
"title": "Merge Request",
"icon": "GitVersion",
"schema": {
"properties": {
"creator": {
"title": "Creator",
"type": "string"
},
"status": {
"title": "Status",
"type": "string",
"enum": ["opened", "closed", "merged", "locked"],
"enumColors": {
"opened": "yellow",
"closed": "red",
"merged": "green",
"locked": "blue"
}
},
"createdAt": {
"title": "Create At",
"type": "string",
"format": "date-time"
},
"updatedAt": {
"title": "Updated At",
"type": "string",
"format": "date-time"
},
"link": {
"title": "Link",
"format": "url",
"type": "string"
}
}
},
"relations": {
"repository": {
"target": "gitlabRepository",
"required": false,
"many": false
}
},
"mirrorProperties": {},
"calculationProperties": {},
}
Ocean integration configuration
resources:
- kind: project
selector:
query: "true"
port:
entity:
mappings:
identifier: .path_with_namespace | gsub(" "; "")
title: .name
blueprint: '"gitlabRepository"'
properties:
url: .web_url
readme: file://README.md
description: .description
language: .__languages | to_entries | max_by(.value) | .key
namespace: .namespace.name
fullPath: .namespace.full_path
defaultBranch: .default_branch
- kind: merge-request
selector:
query: "true"
port:
entity:
mappings:
identifier: .id | tostring
title: .title
blueprint: '"gitlabMergeRequest"'
properties:
creator: .author.name
status: .state
createdAt: .created_at
updatedAt: .updated_at
link: .web_url
relations:
repository: .references.full | gsub("!.+"; "")
了解更多信息
- 请参阅setup 部分,了解集成配置设置过程的更多信息。
- 我们利用JQ JSON processor 将 GitLab 对象映射和转换为 Port 实体。
- 点击Here 查看 GitLab 项目对象结构。
- 点击Here 查看 GitLab 合并请求对象结构。
创建蓝图并保存集成配置后,您将在 Port 中看到与您的项目相匹配的新实体,以及它们的 README.md
文件内容和合并请求。
映射组、分组和项目
在以下示例中,您将把 GitLab 组、子组和项目被用于到 Port,您可以使用以下 Port 蓝图定义和集成配置:
Group blueprint
{
"identifier": "gitlabGroup",
"title": "Group",
"icon": "GitLab",
"schema": {
"properties": {
"visibility": {
"icon": "Lock",
"title": "Visibility",
"type": "string",
"enum": [
"public",
"internal",
"private"
],
"enumColors": {
"public": "red",
"internal": "yellow",
"private": "green"
}
},
"url": {
"title": "URL",
"format": "url",
"type": "string",
"icon": "Link"
},
"description": {
"title": "Description",
"type": "string",
"icon": "BlankPage"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {}
}
Repository blueprint
{
"identifier": "gitlabRepository",
"title": "Repository",
"icon": "Microservice",
"schema": {
"properties": {
"url": {
"title": "URL",
"type": "string",
"format": "url"
},
"readme": {
"title": "README",
"type": "string",
"format": "markdown"
},
"description": {
"title": "Description",
"type": "string"
},
"language": {
"title": "Language",
"type": "string"
},
"namespace": {
"title": "Namespace",
"type": "string"
},
"fullPath": {
"title": "Full Path",
"type": "string"
},
"defaultBranch": {
"title": "Default Branch",
"type": "string"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {
"group": {
"title": "Group",
"target": "gitlabGroup",
"required": true,
"many": false
}
}
}
Ocean integration configuration
deleteDependentEntities: true
createMissingRelatedEntities: true
enableMergeEntity: true
resources:
- kind: group
selector:
query: 'true'
port:
entity:
mappings:
identifier: .full_path
title: .name
blueprint: '"gitlabGroup"'
properties:
url: .web_url
visibility: .visibility
description: .description
- kind: project
selector:
query: 'true'
port:
entity:
mappings:
identifier: .path_with_namespace | gsub(" "; "")
title: .name
blueprint: '"gitlabRepository"'
properties:
url: .web_url
readme: file://README.md
description: .description
language: .__languages | to_entries | max_by(.value) | .key
namespace: .namespace.name
fullPath: .namespace.full_path
defaultBranch: .default_branch
relations:
group: >-
.path_with_namespace | gsub(" "; "") | split("/") | .[:-1] |
join("/")
了解更多信息
- 请参阅setup 部分,了解集成配置设置过程的更多信息。
- 我们利用JQ JSON processor 将 GitLab 对象映射和转换为 Port 实体。
- 单击Here 查看 GitLab 项目对象结构。
- 点击Here 查看 GitLab 子组对象结构。
绘制项目、Pipelines 和工作 图
在下面的示例中,您将把 GitLab 项目及其 Pipelines 和作业运行引用到 Port,您可以使用以下 Port 蓝图定义和集成配置:
Repository blueprint
{
"identifier": "gitlabRepository",
"title": "Repository",
"icon": "Microservice",
"schema": {
"properties": {
"url": {
"title": "URL",
"type": "string",
"format": "url"
},
"readme": {
"title": "README",
"type": "string",
"format": "markdown"
},
"description": {
"title": "Description",
"type": "string"
},
"language": {
"title": "Language",
"type": "string"
},
"namespace": {
"title": "Namespace",
"type": "string"
},
"fullPath": {
"title": "Full Path",
"type": "string"
},
"defaultBranch": {
"title": "Default Branch",
"type": "string"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {}
}
Pipeline blueprint
{
"identifier": "gitlabPipeline",
"title": "Pipeline",
"icon": "GitLab",
"schema": {
"properties": {
"createdAt": {
"title": "Created At",
"type": "string",
"format": "date-time"
},
"updatedAt": {
"title": "Updated At",
"type": "string",
"format": "date-time"
},
"creator": {
"title": "Creator",
"type": "string"
},
"status": {
"title": "Status",
"type": "string",
"enum": [
"created",
"waiting_for_resource",
"preparing",
"pending",
"running",
"success",
"failed",
"canceled",
"skipped",
"manual",
"scheduled"
],
"enumColors": {
"created": "yellow",
"waiting_for_resource": "yellow",
"preparing": "yellow",
"pending": "yellow",
"running": "yellow",
"success": "green",
"failed": "red",
"canceled": "red",
"skipped": "red",
"manual": "blue",
"scheduled": "blue"
}
},
"stages": {
"title": "Stages",
"type": "array",
"items": {
"type": "string"
}
},
"link": {
"title": "Link",
"type": "string",
"format": "url"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {
"repository": {
"title": "Repository",
"target": "gitlabRepository",
"required": true,
"many": false
}
}
}
Job blueprint
{
"identifier": "gitlabJob",
"title": "Job",
"icon": "GitLab",
"schema": {
"properties": {
"createdAt": {
"title": "Created At",
"type": "string",
"format": "date-time"
},
"startedAt": {
"title": "Started At",
"type": "string",
"format": "date-time"
},
"finishedAt": {
"title": "Finished At",
"type": "string",
"format": "date-time"
},
"creator": {
"title": "Creator",
"type": "string"
},
"stage": {
"title": "Stage",
"type": "string"
},
"status": {
"title": "Status",
"type": "string",
"enum": [
"failed",
"warning",
"pending",
"running",
"manual",
"scheduled",
"canceled",
"success",
"skipped",
"created"
],
"enumColors": {
"failed": "red",
"warning": "red",
"pending": "yellow",
"running": "yellow",
"manual": "blue",
"scheduled": "blue",
"canceled": "red",
"success": "green",
"skipped": "red",
"created": "yellow"
}
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {
"pipeline": {
"target": "gitlabPipeline",
"required": false,
"many": false
}
}
}
Ocean integration configuration
resources:
- kind: project
selector:
query: "true"
port:
entity:
mappings:
identifier: .path_with_namespace | gsub(" "; "")
title: .name
blueprint: '"gitlabRepository"'
properties:
url: .web_url
description: .description
language: .__languages | to_entries | max_by(.value) | .key
namespace: .namespace.name
fullPath: .namespace.full_path
defaultBranch: .default_branch
- kind: pipeline
selector:
query: "true"
port:
entity:
mappings:
identifier: .id | tostring
title: .title // (.id | tostring)
blueprint: '"gitlabPipeline"'
properties:
creator: .user.name
status: .status
createdAt: .created_at
updatedAt: .updated_at
description: .description
link: .web_url
relations:
repository: .__project.path_with_namespace | gsub(" "; "")
- kind: job
selector:
query: "true"
port:
entity:
mappings:
identifier: .id | tostring
title: .name
blueprint: '"gitlabJob"'
properties:
creator: .user.name
startedAt: .started_at
updatedAt: .updated_at
finishedAt: .finished_at
stage: .stage
status: .status
link: .web_url
relations:
pipeline: .pipeline.id | tostring
了解更多信息
- 请参阅setup 部分,了解集成配置设置过程的更多信息。
- 我们利用JQ JSON processor 将 GitLab 对象映射和转换为 Port 实体。
- 点击Here 查看 GitLab 项 目对象结构。
- 点击Here 查看 GitLab Pipelines 对象结构。
- 点击Here 查看 GitLab 作业对象结构。
创建蓝图并保存集成配置后,您将在 Port 中看到与您的项目相匹配的新实体,以及它们的 Pipelines 和作业。
映射项目和 monorepos
在以下示例中,您将把 GitLab 项目及其 monorepo 文件夹引用到 Port,您可以使用以下 Port 蓝图定义和集成配置:
Repository blueprint
{
"identifier": "gitlabRepository",
"title": "Repository",
"icon": "Microservice",
"schema": {
"properties": {
"url": {
"title": "URL",
"type": "string",
"format": "url"
},
"readme": {
"title": "README",
"type": "string",
"format": "markdown"
},
"description": {
"title": "Description",
"type": "string"
},
"language": {
"title": "Language",
"type": "string"
},
"namespace": {
"title": "Namespace",
"type": "string"
},
"fullPath": {
"title": "Full Path",
"type": "string"
},
"defaultBranch": {
"title": "Default Branch",
"type": "string"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {}
}
Ocean integration configuration
resources:
- kind: folder
selector:
query: "true" # JQ boolean query. If evaluated to false - skip syncing the object.
folders: # Specify the repositories and folders to include under this relative path.
- path: "apps/" # Relative path to the folders within the repositories.
repos: # List of repositories to include folders from.
- backend-service
- frontend-service
port:
entity:
mappings:
identifier: .folder.name
title: .folder.name
blueprint: '"gitlabProject"'
properties:
url: >-
.repo.web_url + "/tree/" + .repo.default_branch + "/" +
.folder.path
description: .repo.description
namespace: .repo.namespace.name
full_path: .repo.path_with_namespace + "/" + folder.path
language: .repo.__languages | to_entries | max_by(.value) | .key
readme: file://README.md
要了解更多信息 要检索 monorepo 的根文件夹,可以在
port-app-config.yml
中使用以下语法:- kind: folder
selector:
query: "true" # JQ boolean query. If evaluated to false - skip syncing the object.
folders: # Specify the repositories and folders to include under this relative path.
- path: "/" # Relative path to the folders within the repositories
repos: # List of repositories to include folders from.
- backend-service
- frontend-service
tip
例如,您也可以为每个 monorepo 版本库指定不同的路径:
- kind: folder
selector:
query: "true" # JQ boolean query. If evaluated to false - skip syncing the object.
folders: # Specify the repositories and folders to include under this relative path.
- path: "apps/"
repos:
- gaming-apps
- path: "microservices/"
repos:
- backend-services
tip
- 请参阅setup 部分,了解集成配置设置过程的更多信息。
- 我们利用JQ JSON processor 将 GitLab 对象映射和转换为 Port 实体。
- 点击Here 查看 GitLab 项目对象结构。
- 点击Here 查看 GitLab 仓库树对象结构。
映射项目和文件夹
在以下示例中,您将把 GitLab 项目及其文件夹引用到 Port,您可以使用以下 Port 蓝图定义和集成配置:
Repository blueprint
{
"identifier": "gitlabRepository",
"title": "Repository",
"icon": "Microservice",
"schema": {
"properties": {
"url": {
"title": "URL",
"type": "string",
"format": "url"
},
"readme": {
"title": "README",
"type": "string",
"format": "markdown"
},
"description": {
"title": "Description",
"type": "string"
},
"language": {
"title": "Language",
"type": "string"
},
"namespace": {
"title": "Namespace",
"type": "string"
},
"fullPath": {
"title": "Full Path",
"type": "string"
},
"defaultBranch": {
"title": "Default Branch",
"type": "string"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {}
}
Folder blueprint
{
"identifier": "gitlabFolder",
"title": "Folder",
"icon": "Gitlab",
"schema": {
"properties": {
"readme": {
"title": "README",
"type": "string",
"format": "markdown"
},
"url": {
"title": "Folder URL",
"type": "string",
"format": "url"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {
"repository": {
"title": "Repository",
"target": "gitlabRepository",
"required": false,
"many": false
}
}
}
Port port-app-config.yml
resources:
- kind: repository
selector:
query: "true"
port:
entity:
mappings:
identifier: .name
title: .name
blueprint: '"gitlabRepository"'
properties:
readme: file://README.md
url: .web_url
defaultBranch: .default_branch
- kind: folder
selector:
query: "true"
folders:
- path: "/" # Using "/" will ingest the folders from the root of each of repository as entities
repos: # Add any repositories you want to map folders from to the following list
- backend-service
- frontend-service
port:
entity:
mappings:
identifier: .folder.name
title: .folder.name
blueprint: '"gitlabFolder"'
properties:
url: >-
.repo.web_url + "/tree/" + .repo.default_branch + "/" +
.folder.path
readme: file://README.md
relations:
repository: .repo.name
了解更多信息
- 请参阅setup 部分,了解集成配置设置过程的更多信息。
- 我们利用JQ JSON processor 将 GitLab 对象映射和转换为 Port 实体。
- 点击Here 查看 GitLab 项目对象结构。
- 点击Here 查看 GitLab 仓库树对象结构。
绘制项目和问题图
在下面的示例中,您将把 GitLab 项目及其问题引用到 Port,您可以使用以下 Port 蓝图定义和集成配置:
Repository blueprint
{
"identifier": "gitlabRepository",
"title": "Repository",
"icon": "Microservice",
"schema": {
"properties": {
"url": {
"title": "URL",
"type": "string",
"format": "url"
},
"readme": {
"title": "README",
"type": "string",
"format": "markdown"
},
"description": {
"title": "Description",
"type": "string"
},
"language": {
"title": "Language",
"type": "string"
},
"namespace": {
"title": "Namespace",
"type": "string"
},
"fullPath": {
"title": "Full Path",
"type": "string"
},
"defaultBranch": {
"title": "Default Branch",
"type": "string"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {}
}
Issue blueprint
{
"identifier": "gitlabIssue",
"title": "Issue",
"icon": "GitLab",
"schema": {
"properties": {
"link": {
"title": "Link",
"type": "string",
"format": "url"
},
"description": {
"title": "Description",
"type": "string",
"format": "markdown"
},
"createdAt": {
"title": "Created At",
"type": "string",
"format": "date-time"
},
"closedAt": {
"title": "Closed At",
"type": "string",
"format": "date-time"
},
"updatedAt": {
"title": "Updated At",
"type": "string",
"format": "date-time"
},
"creator": {
"title": "Creator",
"type": "string"
},
"status": {
"title": "Status",
"type": "string",
"enum": ["opened", "closed"],
"enumColors": {
"opened": "green",
"closed": "purple"
}
},
"labels": {
"title": "Labels",
"type": "array",
"items": {
"type": "string"
}
}
}
},
"relations": {
"repository": {
"target": "gitlabRepository",
"title": "Repository",
"required": true,
"many": false
}
}
}
Ocean integration configuration
resources:
- kind: project
selector:
query: "true"
port:
entity:
mappings:
identifier: .path_with_namespace | gsub(" "; "")
title: .name
blueprint: '"gitlabRepository"'
properties:
url: .web_url
description: .description
language: .__languages | to_entries | max_by(.value) | .key
namespace: .namespace.name
fullPath: .namespace.full_path
defaultBranch: .default_branch
- kind: issue
selector:
query: "true"
port:
entity:
mappings:
identifier: .id | tostring
title: .title
blueprint: '"gitlabIssue"'
properties:
creator: .author.name
status: .state
createdAt: .created_at
closedAt: .closed_at
updatedAt: .updated_at
description: .description
link: .web_url
labels: "[.labels[]]"
relations:
repository: .references.full | gsub("#.+"; "")
了解更多信息
- 请参阅setup 部分,了解集成配置设置过程的更多信息。
- 我们利用JQ JSON processor 将 GitLab 对象映射和转换为 Port 实体。
- 点击Here 查看 GitLab 项目对象结构。
- 点击Here 查看 GitLab 问题对象结构。
创建蓝图并保存集成配置后,您将在 Port 中看到与项目相匹配的新实体及其问题。
映射支持的资源
上述示例展示了一个特定的使用案例,但 Port 的 GitLab 集成支持摄取许多其他 GitLab 对象,要调整上述示例,请使用 GitLab API 参考资料了解不同支持对象的可用字段:
Available GitLab resources
在添加其他资源的摄取时,请记得在 resources
数组中添加一个条目,并相应更改提供给 kind
键的值。