-
Notifications
You must be signed in to change notification settings - Fork 0
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
Port 11015 add azure dev ops releases #1
base: main
Are you sure you want to change the base?
Changes from all commits
aa2950a
fbbebdb
144b3fb
c090852
f38ef63
26b6670
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,3 +103,23 @@ resources: | |
blueprint: '"column"' | ||
relations: | ||
board: .__board.id | gsub(" "; "") | ||
- kind: release | ||
selector: | ||
query: 'true' | ||
port: | ||
entity: | ||
mappings: | ||
identifier: .id | tostring | gsub(" "; "") | ||
title: .name | ||
blueprint: '"release"' | ||
properties: | ||
status: .status | ||
reason: .reason | ||
createdDate: .createdOn | ||
modifiedDate: .modifiedOn | ||
createdBy: .createdBy.displayName | ||
modifiedBy: .modifiedBy.displayName | ||
Comment on lines
+120
to
+121
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's use the unique name, which will be the email of the user a sample response I saw from the docs
|
||
definitionName: .releaseDefinition.name | ||
link: ._links.web.href | gsub("_release?releaseId="; "") | ||
relations: | ||
project: .projectReference.id | gsub(" "; "") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,11 @@ configurations: | |
required: true | ||
type: url | ||
sensitive: true | ||
- name: vsrmUrl | ||
description: The URL of your Visual Studio Resource Manager, Azure DevOps organization (e.g., "https://vsrm.dev.azure.com/{your-organization}"). To find your organization URL, refer to the <a target="_blank" href="https://learn.microsoft.com/en-us/azure/devops/extend/develop/work-with-urls?view=azure-devops&tabs=http">Azure DevOps documentation</a>. | ||
required: true | ||
type: url | ||
sensitive: true | ||
Comment on lines
+15
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we have the organization from the main ADO url ( |
||
- name: personalAccessToken | ||
description: A personal access token (PAT) with read permissions for the resources you want to sync. To create a PAT, see the <a target="_blank" href="https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops">Azure DevOps documentation</a>. | ||
required: true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,16 +25,18 @@ | |
|
||
|
||
class AzureDevopsClient(HTTPBaseClient): | ||
def __init__(self, organization_url: str, personal_access_token: str) -> None: | ||
def __init__(self, organization_url: str, vsrm_url, personal_access_token: str) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's remove this if the vsrm_url is the same as the ado enterprise url |
||
super().__init__(personal_access_token) | ||
self._organization_base_url = organization_url | ||
self._vsrm_base_url = vsrm_url | ||
|
||
@classmethod | ||
def create_from_ocean_config(cls) -> "AzureDevopsClient": | ||
if cache := event.attributes.get("azure_devops_client"): | ||
return cache | ||
azure_devops_client = cls( | ||
ocean.integration_config["organization_url"], | ||
ocean.integration_config["vsrm_url"], | ||
ocean.integration_config["personal_access_token"], | ||
) | ||
event.attributes["azure_devops_client"] = azure_devops_client | ||
|
@@ -124,6 +126,17 @@ async def generate_pipelines(self) -> AsyncGenerator[list[dict[Any, Any]], None] | |
for pipeline in pipelines: | ||
pipeline["__projectId"] = project["id"] | ||
yield pipelines | ||
|
||
async def generate_releases(self) -> AsyncGenerator[list[dict[str, Any]], None]: | ||
async for projects in self.generate_projects(): | ||
for project in projects: | ||
releases_url = f"{self._vsrm_base_url}/{project['id']}/{API_URL_PREFIX}/release/releases" | ||
async for releases in self._get_paginated_by_top_and_skip(releases_url): | ||
for release in releases: | ||
release["__projectId"] = project["id"] | ||
release["__project"] = project | ||
Comment on lines
+136
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we already get this information from the release response so we may not need this
|
||
yield releases | ||
|
||
|
||
async def generate_repository_policies( | ||
self, | ||
|
@@ -401,3 +414,4 @@ async def get_file_by_commit( | |
return await self._get_item_content( | ||
file_path, repository_id, "Commit", commit_id | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
combine the project id (.projectReference.id | gsub(" "; "")) with the release id to make it unique, so that it doesn't get overridden by other releases in other projects