Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Integration][bitbucket] Added bitbucket ocean integration #1448

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions integrations/bitbucket/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
OCEAN__PORT__CLIENT_ID=Your client ID
OCEAN__PORT__CLIENT_SECRET=Your client secret
OCEAN__INTEGRATION__IDENTIFIER=bitbucket
OCEAN__PORT__BASE_URL=https://api.getport.io
OCEAN__EVENT_LISTENER__TYPE=POLLING
OCEAN__INITIALIZE_PORT_RESOURCES=true
OCEAN__INTEGRATION__CONFIG__BITBUCKET_USERNAME=
OCEAN__INTEGRATION__CONFIG__BITBUCKET_APP_PASSWORD=
OCEAN__INTEGRATION__CONFIG__BITBUCKET_WORKSPACE=
OCEAN__INTEGRATION__CONFIG__BITBUCKET_WORKSPACE_TOKEN=
153 changes: 153 additions & 0 deletions integrations/bitbucket/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/
1 change: 1 addition & 0 deletions integrations/bitbucket/.port/resources/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.gitignore
120 changes: 120 additions & 0 deletions integrations/bitbucket/.port/resources/blueprints.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
[
{
"identifier": "bitbucketProject",
"description": "A software catalog to represent Bitbucket project",
"title": "Bitbucket Project",
"icon": "BitBucket",
"schema": {
"properties": {
"private": {
"icon": "DefaultProperty",
"title": "Private",
"type": "boolean"
},
"description": {
"title": "Description",
"type": "string",
"icon": "DefaultProperty"
},
"type": {
"icon": "DefaultProperty",
"title": "Type",
"type": "string"
},
"url": {
"title": "Url",
"icon": "DefaultProperty",
"type": "string"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {}
},
{
"identifier": "bitbucketRepository",
"title": "Repository",
"icon": "Microservice",
"schema": {
"properties": {
"readme": {
"title": "README",
"type": "string",
"format": "markdown"
},
"url": {
"title": "Repository URL",
"type": "string",
"format": "url"
},
"defaultBranch": {
"title": "Default branch",
"type": "string"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {}
},
{
"identifier": "bitbucketPullRequest",
"title": "Pull Request",
"icon": "GitVersion",
"schema": {
"properties": {
"creator": {
"title": "Creator",
"type": "string",
"format": "user"
},
"status": {
"title": "Status",
"type": "string",
"enum": ["MERGED","OPEN","DECLINED"],
"enumColors": {
"MERGED": "purple",
"OPEN": "green",
"DECLINED": "red"
}
},
"createdAt": {
"title": "Created At",
"type": "string",
"format": "date-time"
},
"updatedAt": {
"title": "Updated At",
"type": "string",
"format": "date-time"
},
"link": {
"title": "Link",
"format": "url",
"type": "string"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {
"lead_time_days": {
"title": "Lead time (Days)",
"calculation": "if .properties.status == \"MERGED\" then ((.properties.updatedAt | sub(\"\\\\.[0-9]+\\\\+00:00$\"; \"Z\") | strptime(\"%Y-%m-%dT%H:%M:%SZ\") | mktime) - (.properties.createdAt | sub(\"\\\\.[0-9]+\\\\+00:00$\"; \"Z\") | strptime(\"%Y-%m-%dT%H:%M:%SZ\") | mktime)) / 86400 | tonumber else null end",
"type": "number"
}
},
"aggregationProperties": {},
"relations": {
"repository": {
"title": "Repository",
"target": "bitbucketRepository",
"required": false,
"many": false
}
}
}
]
45 changes: 45 additions & 0 deletions integrations/bitbucket/.port/resources/port-app-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
resources:
- kind: project
selector:
query: "true"
port:
entity:
mappings:
identifier: '.uuid | gsub("[{-}]"; "")'
title: ".name"
blueprint: '"bitbucketProject"'
properties:
private: .is_private
description: ".description"
type: .type
url: ".links.html.href"
- kind: repository
selector:
query: "true"
port:
entity:
mappings:
identifier: ".name"
title: ".name"
blueprint: '"bitbucketRepository"'
properties:
url: ".links.html.href"
defaultBranch: .mainbranch.name
- kind: pull-request
selector:
query: "true"
port:
entity:
mappings:
identifier: ".destination.repository.name + (.id|tostring)"
title: ".title"
blueprint: '"bitbucketPullRequest"'
properties:
creator: ".author.display_name"
status: ".state"
createdAt: ".created_on"
updatedAt: ".updated_on"
link: ".links.html.href"
relations:
repository: ".destination.repository.name"

27 changes: 27 additions & 0 deletions integrations/bitbucket/.port/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
description: bitbucket integration for Port Ocean
icon: bitbucket
features:
- type: exporter
section: Git Providers
resources:
- kind: project
- kind: repository
- kind: pull-request
configurations:
- name: bitbucketWorkspaceToken
type: string
sensitive: true
description: Bitbucket access token
- name: appHost
type: url
description: The host of the Port Ocean app. Used to set up the integration endpoint as the target for Webhooks created in Bitbucket.
- name: bitbucketUsername
type: string
description: The username of the Bitbucket account.
- name: bitbucketWorkspace
description: The slug of the workspace the integration will handle
type: string
- name: bitbucketAppPassword
type: string
sensitive: true
description: Bitbucket access token
15 changes: 15 additions & 0 deletions integrations/bitbucket/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog - Ocean - bitbucket

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<!-- towncrier release notes start -->

## 0.1.0-beta (2025-03-03)


### Features

- Created bitbucket ocean integration with support for Project, Repository, Folder and Pull Request kinds
7 changes: 7 additions & 0 deletions integrations/bitbucket/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Contributing to Ocean - bitbucket

## Running locally

#### NOTE: Add your own instructions of how to run bitbucket

This could be any gotcha's such as rate limiting, how to setup credentials and so forth
1 change: 1 addition & 0 deletions integrations/bitbucket/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../_infra/Makefile
7 changes: 7 additions & 0 deletions integrations/bitbucket/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# bitbucket

An integration used to import bitbucket resources into Port.

#### Install & use the integration - [Integration documentation](https://docs.getport.io/build-your-software-catalog/sync-data-to-catalog/) *Replace this link with a link to this integration's documentation*

#### Develop & improve the integration - [Ocean integration development documentation](https://ocean.getport.io/develop-an-integration/)
Loading