forked from microsoft/azure-devops-python-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
43 lines (28 loc) · 945 Bytes
/
build.py
File metadata and controls
43 lines (28 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
Build samples.
"""
import logging
from samples import resource
from utils import emit, find_any_project, find_any_build_definition
logger = logging.getLogger(__name__)
@resource('definition')
def get_definitions(context):
project = find_any_project(context)
emit(project.name)
build_client = context.connection.clients.get_build_client()
definitions = build_client.get_definitions(project.id)
for definition in definitions:
emit(str(definition.id) + ": " + definition.name)
return definitions
@resource('build')
def queue_build(context):
definition = find_any_build_definition(context)
build_client = context.connection.clients.get_build_client()
build = {
'definition': {
'id': definition.id
}
}
response = build_client.queue_build(build=build, project=definition.project.id)
emit(str(response.id) + ": " + response.url)
return response