Unverified Commit b25a8641 authored by Marco Schlicht's avatar Marco Schlicht
Browse files

added pipeline

parent c70d9257
Pipeline #283269 passed with stages
in 7 minutes and 54 seconds
image: tiangolo/docker-with-compose
variables:
MAIN_DOCKER_FILE: "Dockerfile"
VERSION_FILE: "version.txt"
stages:
- check_version_merge_to_master
- check_version
- git_tag
- release
before_script:
- apt update
- apt install -y python3
- python3 -V
- uname -a
unittest:
image: debian:stretch
stage: test
script:
- apt update
- apt install -y sqlite3 locales-all python3-flask python3-ldap3 python3-requests python3-pillow python3-coverage
- python3 -m coverage run tests.py
- python3 -m coverage report --include "./*"
- python3 -m coverage report -m --include "./*" > report.txt
- python3 -m coverage html --include "./*"
artifacts:
paths:
- htmlcov/*
- .coverage
- report.txt
- echo "$CI_JOB_TOKEN" | docker login --username gitlab-ci-token --password-stdin "$CI_REGISTRY"
.check_version:
script:
- VERSION=$(cat $VERSION_FILE)
- VERSION="v$VERSION"
- tmp=0; DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect "$CI_REGISTRY_IMAGE":"$VERSION" || tmp=$?
- test $tmp -ne 0 # if this goes wrong, the version already exists in docker registry
- apk add git
- git fetch --tags
- tmp=0; git rev-parse "$VERSION" || tmp=$?
- test $tmp -ne 0 # if this goes wrong, the version already exists in git tags
check_version_merge_to_master:
extends: .check_version
stage: check_version_merge_to_master
only:
- merge_requests
except:
variables:
- $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "master" # only merge requests to master
check_version:
extends: .check_version
stage: check_version
only:
- master
except:
variables:
- $CI_COMMIT_MESSAGE =~ /force release/ # skip this step if commit message contains "force release"
git_tag:
stage: git_tag
only:
- master
script:
- VERSION=$(cat $VERSION_FILE)
- VERSION="v$VERSION"
- apk add git
- git remote set-url origin "https://gitlab-ci-token:${GITLAB_ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}"
- git tag -f "$VERSION"
- git push -f --tags
########
# MASTER
########
release:
stage: release
only:
- master
script:
- VERSION=$(cat $VERSION_FILE)
- VERSION="v$VERSION"
- docker build --pull --cache-from "$CI_REGISTRY_IMAGE":latest --tag "$CI_REGISTRY_IMAGE":latest -f "$MAIN_DOCKER_FILE" .
- docker tag "$CI_REGISTRY_IMAGE":latest "$CI_REGISTRY_IMAGE":"$VERSION"
- docker push "$CI_REGISTRY_IMAGE":latest
- docker push "$CI_REGISTRY_IMAGE":"$VERSION"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment