forked from Unity-Technologies/mono
-
Notifications
You must be signed in to change notification settings - Fork 1
/
reportCiResult.py
34 lines (28 loc) · 1.07 KB
/
reportCiResult.py
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
#!/usr/bin/env python2.7
import os
import sys
import textwrap
def post_to_github(context, state, description=None):
if 'GITHUB_TOKEN' not in os.environ:
print 'NOT posting results to GitHub ($GITHUB_TOKEN not available)'
return
payload = dict(
context=context,
state=state,
#target_url="{CI_PROJECT_URL}/-/jobs/{CI_BUILD_ID}".format(**os.environ),
target_url="{CI_PROJECT_URL}/pipelines/{CI_PIPELINE_ID}".format(**os.environ),
)
if description:
payload.update(dict(description=description))
import requests
print 'sending status to github...'
print 'sending to: {GITHUB_REPO_API}/statuses/{CI_COMMIT_SHA}'.format(**os.environ)
print 'Bearer {GITHUB_TOKEN}'.format(**os.environ)
response = requests.post(
'{GITHUB_REPO_API}/statuses/{CI_COMMIT_SHA}'.format(**os.environ),
headers={'Authorization': 'Bearer {GITHUB_TOKEN}'.format(**os.environ)},
json=payload,
)
print response.text
os.system('pip install requests')
post_to_github(context=sys.argv[1], state=sys.argv[2])