-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathappveyor_logs
executable file
·33 lines (26 loc) · 1001 Bytes
/
appveyor_logs
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
#!/usr/bin/env python3
# A simple helper script to retrieve AppVeyor logs from the command line.
#
# Set the following git config variables:
# $ git config appveyor.token 'Your AppVeyor Toekn'
# $ git config appveyor.slug = 'user/project'
#
from urllib.request import Request, urlopen
import json
from subprocess import check_output
def git_config(key):
return check_output(['git', 'config', key]).decode('UTF-8').strip()
def slug():
return git_config('appveyor.slug')
def token():
return git_config('appveyor.token')
api = 'https://ci.appveyor.com/api/'
if __name__ == '__main__':
req = Request(api + 'projects/' + slug())
req.add_header('Authorization', 'Bearer ' + token())
with urlopen(req) as api_resp:
info = json.loads(api_resp.read().decode('UTF-8'))
jobId = info['build']['jobs'][0]['jobId']
with urlopen(api + 'buildjobs/' + jobId + '/log') as log:
print(log.read().decode('UTF-8'))
print(api + 'projects/' + slug() + '/artifacts/Release/bmc.exe')