Create rolling releases using the Gitlab API. (#171)

* Create rolling releases using the Gitlab API.

This commit builds rolling releases of Container images using the latest commit
on master branch if the pipeline passed for it. The script which gets the
references is still un-tested and should be tested.

The latest commit hashes are passed as arguments to the Dockerfile, which is
then used by PIP to install the specific version of the dependency.
This commit is contained in:
Abhilash Raj
2017-11-03 18:43:59 -07:00
committed by GitHub
parent 743bc8522c
commit 3434446987
9 changed files with 127 additions and 45 deletions

38
get_latest_ref.py Executable file
View File

@@ -0,0 +1,38 @@
#! /usr/bin/env python
import os
import sys
import gitlab
def usage():
print("{} <project_name> <project_branch>")
def main():
if 2 > len(sys.argv) > 3:
usage()
project_name = sys.argv[1]
if len(sys.argv) > 2:
branch_name = sys.argv[2]
else:
branch_name = 'master'
gl_token = os.getenv('GITLAB_TOKEN')
if gl_token is None:
print('GITLAB_TOKEN not set!')
exit(1)
gl = gitlab.Gitlab('https://gitlab.com/', gl_token)
project = gl.projects.get(project_name)
branch = project.branches.get(branch_name)
top_commit = project.commits.get(branch.commit['short_id'])
if top_commit.last_pipeline['status'] == 'success':
print(top_commit.short_id)
else:
exit(1)
if __name__ == '__main__':
main()