This is an automated email from the ASF dual-hosted git repository.

lynwee pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new cfe3d64bb [AzureDevops ] fix: some fields' values (#7013)
cfe3d64bb is described below

commit cfe3d64bb58149f7c82b5d7a1b55218e29242a0b
Author: Lynwee <[email protected]>
AuthorDate: Mon Feb 26 16:24:43 2024 +0800

    [AzureDevops ] fix: some fields' values (#7013)
    
    * fix(auzredevops): remove update_date from repos and cicd_scopes
    
    * fix(azuredevops): fix environment field in cicd_tasks and cicd_pipelins
    
    * fix(azuredevops): fix enviroment field in cicd_tasks and cicd_pipelines
---
 .../python/plugins/azuredevops/azuredevops/main.py   |  4 ++--
 .../azuredevops/azuredevops/streams/builds.py        |  8 +++++---
 .../plugins/azuredevops/azuredevops/streams/jobs.py  | 20 ++++++++++----------
 .../azuredevops/azuredevops/streams/pull_requests.py |  2 +-
 .../pydevlake/pydevlake/domain_layer/devops.py       |  2 +-
 5 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/backend/python/plugins/azuredevops/azuredevops/main.py 
b/backend/python/plugins/azuredevops/azuredevops/main.py
index 966aca974..d31b53b3d 100644
--- a/backend/python/plugins/azuredevops/azuredevops/main.py
+++ b/backend/python/plugins/azuredevops/azuredevops/main.py
@@ -51,13 +51,13 @@ class AzureDevOpsPlugin(Plugin):
             name=git_repo.name,
             url=git_repo.url,
             forked_from=git_repo.parent_repository_url,
-            updated_date=git_repo.updated_date,
+            # updated_date=git_repo.updated_date,
         )
         yield CicdScope(
             name=git_repo.name,
             description=git_repo.name,
             url=git_repo.url,
-            updatedDate=git_repo.updated_date,
+            # updatedDate=git_repo.updated_date,
         )
 
     def remote_scope_groups(self, connection) -> list[RemoteScopeGroup]:
diff --git a/backend/python/plugins/azuredevops/azuredevops/streams/builds.py 
b/backend/python/plugins/azuredevops/azuredevops/streams/builds.py
index b24dc1be8..da44bc03c 100644
--- a/backend/python/plugins/azuredevops/azuredevops/streams/builds.py
+++ b/backend/python/plugins/azuredevops/azuredevops/streams/builds.py
@@ -62,9 +62,11 @@ class Builds(Stream):
         type = devops.CICDType.BUILD
         if ctx.scope_config.deployment_pattern and 
ctx.scope_config.deployment_pattern.search(b.name):
             type = devops.CICDType.DEPLOYMENT
-        environment = devops.CICDEnvironment.TESTING
-        if ctx.scope_config.production_pattern and 
ctx.scope_config.production_pattern.search(b.name):
-            environment = devops.CICDEnvironment.PRODUCTION
+
+        environment = devops.CICDEnvironment.PRODUCTION
+        if ctx.scope_config.production_pattern is not None and 
ctx.scope_config.production_pattern.search(
+                b.name) is None:
+            environment = ""
 
         if b.finish_time:
             duration_sec = abs(b.finish_time.timestamp() - 
b.start_time.timestamp())
diff --git a/backend/python/plugins/azuredevops/azuredevops/streams/jobs.py 
b/backend/python/plugins/azuredevops/azuredevops/streams/jobs.py
index 06a6e481a..dae50ad47 100644
--- a/backend/python/plugins/azuredevops/azuredevops/streams/jobs.py
+++ b/backend/python/plugins/azuredevops/azuredevops/streams/jobs.py
@@ -13,16 +13,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import Iterable
-
 from http import HTTPStatus
+from typing import Iterable
 
+import pydevlake.domain_layer.devops as devops
 from azuredevops.api import AzureDevOpsAPI
 from azuredevops.models import Job, Build, GitRepository
 from azuredevops.streams.builds import Builds
 from pydevlake import Context, Substream, DomainType
 from pydevlake.api import APIException
-import pydevlake.domain_layer.devops as devops
 
 
 class Jobs(Substream):
@@ -81,12 +80,13 @@ class Jobs(Substream):
         type = devops.CICDType.BUILD
         if ctx.scope_config.deployment_pattern and 
ctx.scope_config.deployment_pattern.search(j.name):
             type = devops.CICDType.DEPLOYMENT
-        environment = devops.CICDEnvironment.TESTING
-        if ctx.scope_config.production_pattern and 
ctx.scope_config.production_pattern.search(j.name):
-            environment = devops.CICDEnvironment.PRODUCTION
+        environment = devops.CICDEnvironment.PRODUCTION
+        if ctx.scope_config.production_pattern is not None and 
ctx.scope_config.production_pattern.search(
+                j.name) is None:
+            environment = ""
 
         if j.finish_time:
-            duration_sec = 
abs(j.finish_time.timestamp()-j.start_time.timestamp())
+            duration_sec = abs(j.finish_time.timestamp() - 
j.start_time.timestamp())
         else:
             duration_sec = float(0.0)
 
@@ -95,10 +95,10 @@ class Jobs(Substream):
             name=j.name,
             pipeline_id=j.build_id,
             status=status,
-            original_status = str(j.state),
-            original_result = str(j.result),
+            original_status=str(j.state),
+            original_result=str(j.result),
             created_date=j.start_time,
-            started_date =j.start_time,
+            started_date=j.start_time,
             finished_date=j.finish_time,
             result=result,
             type=type,
diff --git 
a/backend/python/plugins/azuredevops/azuredevops/streams/pull_requests.py 
b/backend/python/plugins/azuredevops/azuredevops/streams/pull_requests.py
index bebb7bed8..77cc118b0 100644
--- a/backend/python/plugins/azuredevops/azuredevops/streams/pull_requests.py
+++ b/backend/python/plugins/azuredevops/azuredevops/streams/pull_requests.py
@@ -64,7 +64,7 @@ class GitPullRequests(Stream):
             merged_date=pr.closed_date,
             closed_date=pr.closed_date,
             type=pr.type,
-            component="", # not supported
+            component="",  # not supported
             merge_commit_sha=pr.merge_commit_sha,
             head_ref=pr.source_ref_name,
             base_ref=pr.target_ref_name,
diff --git a/backend/python/pydevlake/pydevlake/domain_layer/devops.py 
b/backend/python/pydevlake/pydevlake/domain_layer/devops.py
index 3ac97fedd..80630e170 100644
--- a/backend/python/pydevlake/pydevlake/domain_layer/devops.py
+++ b/backend/python/pydevlake/pydevlake/domain_layer/devops.py
@@ -66,7 +66,7 @@ class CICDPipeline(DomainModel, table=True):
     queued_duration_sec: Optional[float]
 
     type: Optional[CICDType]
-    environment: Optional[str]
+    environment: Optional[CICDEnvironment]
 
 
 class CiCDPipelineCommit(NoPKModel, table=True):

Reply via email to