Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
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

Expand Down Expand Up @@ -235,4 +236,22 @@ collate_builds:
artifacts:
paths:
- collectedbuilds/builds.7z
expire_in: 1 week
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"
34 changes: 34 additions & 0 deletions reportCiResult.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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])