Skip to content
Snippets Groups Projects
Commit a475ab1d authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Ci upgrade

parent 500d5ba8
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,7 @@ before_script: ...@@ -17,7 +17,7 @@ before_script:
test: test:
stage: test stage: test
script: script:
- git diff-tree --no-commit-id --name-only -r HEAD - git --no-pager diff --name-only origin/master
- python publish_images.py -q - python publish_images.py -q
tags: tags:
- docker - docker
......
...@@ -5,12 +5,15 @@ import sys ...@@ -5,12 +5,15 @@ import sys
import time import time
REGISTRY_URL = 'docker.km3net.de' REGISTRY_URL = 'docker.km3net.de'
SKIP_PUSH = '-q' in sys.argv IS_TEST_BRANCH = '-t' in sys.argv
def get_changed_dockerfiles(): def get_changed_dockerfiles(vs_master=False):
"""Checks the last Git commit and returns a list of changed Dockefiles""" """Checks the last Git commit and returns a list of changed Dockefiles"""
diff_cmd = "git diff-tree --no-commit-id --name-only -r HEAD" if vs_master:
diff_cmd = "git --no-pager diff --name-only master"
else:
diff_cmd = "git diff-tree --no-commit-id --name-only -r HEAD"
child = sp.Popen(diff_cmd, shell=True, stdout=sp.PIPE, stderr=sp.PIPE) child = sp.Popen(diff_cmd, shell=True, stdout=sp.PIPE, stderr=sp.PIPE)
out, _ = child.communicate() out, _ = child.communicate()
...@@ -20,7 +23,7 @@ def get_changed_dockerfiles(): ...@@ -20,7 +23,7 @@ def get_changed_dockerfiles():
def main(): def main():
changed_dockerfiles = get_changed_dockerfiles() changed_dockerfiles = get_changed_dockerfiles(vs_master=IS_TEST_BRANCH)
n_files = len(changed_dockerfiles) n_files = len(changed_dockerfiles)
if n_files == 0: if n_files == 0:
...@@ -35,9 +38,9 @@ def main(): ...@@ -35,9 +38,9 @@ def main():
steps = [("Building", steps = [("Building",
"docker build --pull -t {0}/{1} -f {1} . ".format( "docker build --pull -t {0}/{1} -f {1} . ".format(
REGISTRY_URL, fname))] REGISTRY_URL, fname))]
if not SKIP_PUSH: if not IS_TEST_BRANCH:
steps.append(("Pushing", "docker push {0}/{1}".format(REGISTRY_URL, steps.append(
fname))) ("Pushing", "docker push {0}/{1}".format(REGISTRY_URL, fname)))
else: else:
print("Skiping push...") print("Skiping push...")
...@@ -45,8 +48,10 @@ def main(): ...@@ -45,8 +48,10 @@ def main():
for step, cmd in steps: for step, cmd in steps:
print("{} {} '{}'".format(progress, step, fname)) print("{} {} '{}'".format(progress, step, fname))
child = sp.Popen( child = sp.Popen(cmd,
cmd, shell=True, stdout=sys.stdout, stderr=sys.stderr) shell=True,
stdout=sys.stdout,
stderr=sys.stderr)
child.communicate() child.communicate()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment