in backend/python/plugins/azuredevops/azuredevops/streams/builds.py [0:0]
def convert(self, b: Build, ctx: Context):
if not b.start_time:
return
result = devops.CICDResult.RESULT_DEFAULT
if b.result == Build.BuildResult.Canceled:
result = devops.CICDResult.FAILURE
elif b.result == Build.BuildResult.Failed:
result = devops.CICDResult.FAILURE
elif b.result == Build.BuildResult.PartiallySucceeded:
result = devops.CICDResult.FAILURE
elif b.result == Build.BuildResult.Succeeded:
result = devops.CICDResult.SUCCESS
status = devops.CICDStatus.STATUS_OTHER
if b.status == Build.BuildStatus.Cancelling:
status = devops.CICDStatus.DONE
elif b.status == Build.BuildStatus.Completed:
status = devops.CICDStatus.DONE
elif b.status == Build.BuildStatus.InProgress:
status = devops.CICDStatus.IN_PROGRESS
elif b.status == Build.BuildStatus.NotStarted:
status = devops.CICDStatus.IN_PROGRESS
elif b.status == Build.BuildStatus.Postponed:
status = devops.CICDStatus.IN_PROGRESS
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.PRODUCTION
if ctx.scope_config.production_pattern is not None and ctx.scope_config.production_pattern.search(
b.name) is None:
environment = None
if b.finish_time:
duration_sec = abs(b.finish_time.timestamp() - b.start_time.timestamp())
else:
duration_sec = float(0.0)
yield devops.CICDPipeline(
name=b.name,
status=status,
result=result,
original_status=str(b.status),
original_result=str(b.result),
created_date=b.queue_time,
queued_date=b.queue_time,
started_date=b.start_time,
finished_date=b.finish_time,
duration_sec=duration_sec,
environment=environment,
type=type,
cicd_scope_id=ctx.scope.domain_id(),
display_title=b.display_title,
url=b.url,
)
if b.source_version is not None:
yield devops.CiCDPipelineCommit(
pipeline_id=b.domain_id(),
commit_sha=b.source_version,
branch=b.source_branch,
repo_id=ctx.scope.domain_id(),
repo_url=ctx.scope.url,
display_title=b.display_title,
url=b.url,
)