File tree Expand file tree Collapse file tree 2 files changed +63
-10
lines changed Expand file tree Collapse file tree 2 files changed +63
-10
lines changed Original file line number Diff line number Diff line change 1
1
stages :
2
- - runall
2
+ - runall-and-report-to-github-pending
3
3
- build
4
4
- collate
5
-
6
- # This is just a config to help trigger rest of the builds
7
- run_all_builds :
8
- image : ubuntu:latest
9
- stage : runall
10
- variables :
11
- GIT_STRATEGY : none
5
+ - report-to-github-done
6
+
7
+ # ##############################################################################
8
+ # report result to github
9
+ # ##############################################################################
10
+ runall-and-report-to-github-pending :
11
+ image : python:2.7
12
+ stage : runall-and-report-to-github-pending
12
13
script :
13
- - pwd
14
+ - python reportCiResult.py "gitlab-ci" "pending"
14
15
when : manual
15
16
allow_failure : false
16
17
@@ -235,4 +236,22 @@ collate_builds:
235
236
artifacts :
236
237
paths :
237
238
- collectedbuilds/builds.7z
238
- expire_in : 1 week
239
+ expire_in : 1 week
240
+
241
+
242
+ # ##############################################################################
243
+ # report result to github
244
+ # ##############################################################################
245
+ report-to-github-done:failure :
246
+ image : python:2.7
247
+ when : on_failure
248
+ stage : report-to-github-done
249
+ script :
250
+ - python reportCiResult.py "gitlab-ci" "failure"
251
+
252
+ report-to-github-done:success :
253
+ image : python:2.7
254
+ when : on_success
255
+ stage : report-to-github-done
256
+ script :
257
+ - python reportCiResult.py "gitlab-ci" "success"
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python2.7
2
+
3
+ import os
4
+ import sys
5
+ import textwrap
6
+
7
+ def post_to_github (context , state , description = None ):
8
+ if 'GITHUB_TOKEN' not in os .environ :
9
+ print 'NOT posting results to GitHub ($GITHUB_TOKEN not available)'
10
+ return
11
+
12
+ payload = dict (
13
+ context = context ,
14
+ state = state ,
15
+ #target_url="{CI_PROJECT_URL}/-/jobs/{CI_BUILD_ID}".format(**os.environ),
16
+ target_url = "{CI_PROJECT_URL}/pipelines/{CI_PIPELINE_ID}" .format (** os .environ ),
17
+ )
18
+
19
+ if description :
20
+ payload .update (dict (description = description ))
21
+
22
+ import requests
23
+ print 'sending status to github...'
24
+ print 'sending to: {GITHUB_REPO_API}/statuses/{CI_COMMIT_SHA}' .format (** os .environ )
25
+ print 'Bearer {GITHUB_TOKEN}' .format (** os .environ )
26
+ response = requests .post (
27
+ '{GITHUB_REPO_API}/statuses/{CI_COMMIT_SHA}' .format (** os .environ ),
28
+ headers = {'Authorization' : 'Bearer {GITHUB_TOKEN}' .format (** os .environ )},
29
+ json = payload ,
30
+ )
31
+ print response .text
32
+
33
+ os .system ('pip install requests' )
34
+ post_to_github (context = sys .argv [1 ], state = sys .argv [2 ])
You can’t perform that action at this time.
0 commit comments