Skip to content

Commit 84a9f4a

Browse files
committed
refactor: jenkins utils
1 parent ce003e4 commit 84a9f4a

File tree

5 files changed

+42
-23
lines changed

5 files changed

+42
-23
lines changed

core/utils/ci/__init__.py

Whitespace-only changes.

core/utils/ci/jenkins.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
Jenkins utils.
3+
"""
4+
import os
5+
6+
from core.utils.ci.pr_info import PRInfo
7+
8+
9+
class Jenkins(object):
10+
@staticmethod
11+
def is_ci():
12+
jenkins_home = os.environ.get('JENKINS_HOME', '')
13+
if jenkins_home == '':
14+
return False
15+
else:
16+
return True
17+
18+
@staticmethod
19+
def is_pr():
20+
pr = Jenkins.get_pr_info()
21+
if pr.id is not None:
22+
return True
23+
else:
24+
return False
25+
26+
@staticmethod
27+
def get_pr_info():
28+
return PRInfo(id=os.environ.get('ghprbPullId', None),
29+
author=os.environ.get('ghprbPullAuthorLogin', None),
30+
title=os.environ.get('ghprbPullTitle', None),
31+
description=os.environ.get('ghprbPullLongDescription', None),
32+
target_branch=os.environ.get('ghprbTargetBranch', None),
33+
source_branch=os.environ.get('ghprbSourceBranch', None))

core/utils/ci/pr_info.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class PRInfo(object):
2+
def __init__(self, id=None, author=None, title=None, description=None, target_branch=None, source_branch=None):
3+
self.id = id
4+
self.author = author
5+
self.title = title
6+
self.description = description
7+
self.target_branch = target_branch
8+
self.source_branch = source_branch

core/utils/jenkins.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/cli/smoke/smoke_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from core.enums.os_type import OSType
66
from core.enums.platform_type import Platform
77
from core.settings import Settings
8+
from core.utils.ci.jenkins import Jenkins
89
from core.utils.device.device_manager import DeviceManager
9-
from core.utils.jenkins import Jenkins
1010
from data.sync_helpers import SyncHelpers
1111
from data.templates import Template
1212
from products.nativescript.tns import Tns

0 commit comments

Comments
 (0)