Completed
Pull Request — master (#334)
by
unknown
02:09
created

GetBuildNumberAction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %
Metric Value
wmc 4
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 17 4
1
import httplib
2
3
from lib.action import CircleCI
4
5
6
class GetBuildNumberAction(CircleCI):
7
8
    def run(self, vcs_revision, project, search_limit=10):
9
        """
10
        Get build number for a SHA in project.
11
        """
12
        path = 'project/' + project
13
14
        response = self._perform_request(
15
            path, method='GET',
16
            extra_headers={'limit': int(search_limit)}
17
        )
18
19
        if response.status_code != httplib.OK:
20
            raise Exception('Project %s not found.' % project)
21
22
        for build in response.json:
23
            if build['vcs_revision'] == vcs_revision:
24
                return build['build_number']
25