提交 9e982c6a 编写于 作者: A ashwini

Report status to github

上级 79cdad98
stages:
- runall
- runall-and-report-to-github-pending
- build
- collate
# This is just a config to help trigger rest of the builds
run_all_builds:
image: ubuntu:latest
stage: runall
variables:
GIT_STRATEGY: none
- report-to-github-done
###############################################################################
# report result to github
###############################################################################
runall-and-report-to-github-pending:
image: python:2.7
stage: runall-and-report-to-github-pending
script:
- pwd
- python reportCiResult.py "gitlab-ci" "pending"
when: manual
allow_failure: false
......@@ -235,4 +236,22 @@ collate_builds:
artifacts:
paths:
- collectedbuilds/builds.7z
expire_in: 1 week
\ No newline at end of file
expire_in: 1 week
###############################################################################
# report result to github
###############################################################################
report-to-github-done:failure:
image: python:2.7
when: on_failure
stage: report-to-github-done
script:
- python reportCiResult.py "gitlab-ci" "failure"
report-to-github-done:success:
image: python:2.7
when: on_success
stage: report-to-github-done
script:
- python reportCiResult.py "gitlab-ci" "success"
\ No newline at end of file
#!/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])
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册