Commit ab04ae29 authored by Hispanico's avatar Hispanico

Merge branch 'develop' into 'master'

Updated gitlab-ci and test script

See merge request !6
parents 197e3806 8f1f0153
Pipeline #432 passed with stage
in 1 second
stages:
- build
- test
- release
variables:
CONTAINER_TEST_IMAGE_CENTOS6: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:6
CONTAINER_TEST_IMAGE_CENTOS7: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:7
CONTAINER_RELEASE_IMAGE_CENTOS6: $CI_REGISTRY_IMAGE/released:6
CONTAINER_RELEASE_IMAGE_CENTOS7: $CI_REGISTRY_IMAGE/released:7
CONTAINER_RELEASE_IMAGE_LATEST: $CI_REGISTRY_IMAGE/released:latest
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME
CONTAINER_DEV_IMAGE: $CI_REGISTRY_IMAGE/develop
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE
CONTAINER_ID: '$CI_JOB_NAME-$CI_PROJECT_NAME-Pipeline$CI_PIPELINE_ID-Job$CI_JOB_ID'
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
build:
.build_template: &docker_build
tags:
- docker-builder
- docker-tester
stage: build
script:
- docker build --pull -t $CONTAINER_TEST_IMAGE_CENTOS6 Dockerfile.centos6
- docker push $CONTAINER_TEST_IMAGE_CENTOS6
- docker build --pull -t $CONTAINER_TEST_IMAGE_CENTOS7 Dockerfile.centos7
- docker push $CONTAINER_TEST_IMAGE_CENTOS7
- docker build --pull -t $CONTAINER_TEST_IMAGE:$TAG -f Dockerfile.$DISTRO .
- docker push $CONTAINER_TEST_IMAGE:$TAG
except:
- master
.test:
.test_template: &test_image
tags:
- docker-tester
stage: test
script:
- docker pull $CONTAINER_TEST_IMAGE
# Test running the container.
- docker run --name $CONTAINER_ID $CONTAINER_TEST_IMAGE /script/to/run/tests
# Remove test-container
- docker rm -f $CONTAINER_ID
release-image:
- chmod +x ${PWD}/tests/test.sh
- docker pull $CONTAINER_TEST_IMAGE:$TAG
# Runnig tests on container
- docker run --name $CONTAINER_ID --rm -i -v "$CI_PROJECT_DIR/tests":/tests:rw $CONTAINER_TEST_IMAGE:$TAG /tests/test.sh
except:
- master
.release-image: &release_image
tags:
- docker-builder
stage: release
script:
- docker pull $CONTAINER_TEST_IMAGE_CENTOS6
- docker push $CONTAINER_RELEASE_IMAGE_CENTOS6
- docker pull $CONTAINER_TEST_IMAGE_CENTOS7
- docker push $CONTAINER_RELEASE_IMAGE_CENTOS7
- docker tag $CONTAINER_RELEASE_IMAGE_CENTOS7 $CONTAINER_RELEASE_IMAGE_LATEST
- docker push $CONTAINER_RELEASE_IMAGE_LATEST
- docker pull $CONTAINER_DEV_IMAGE:$TAG
- docker tag $CONTAINER_DEV_IMAGE:$TAG $CONTAINER_RELEASE_IMAGE:$RELEASE_TAG
- docker push $CONTAINER_RELEASE_IMAGE:$RELEASE_TAG
only:
- master
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
build_centos6:
variables:
DISTRO: centos6
TAG: 6
<<: *docker_build
build_centos7:
variables:
DISTRO: centos7
TAG: 7
<<: *docker_build
test_centos6:
variables:
DISTRO: centos6
TAG: 6
<<: *test_image
test_centos7:
variables:
DISTRO: centos7
TAG: 7
<<: *test_image
release-image_centos6:
variables:
TAG: 6
RELEASE_TAG: 6
<<: *release_image
release-image_centos7:
variables:
TAG: 7
RELEASE_TAG: 7
<<: *release_image
release-image_latest:
variables:
TAG: 7
RELEASE_TAG: latest
<<: *release_image
......@@ -5,3 +5,5 @@ ENV container=docker
RUN yum install -y epel-release && \
yum install -y rpmdevtools yum-utils fakeroot && \
yum clean all
CMD ["/bin/bash/bash"]
......@@ -4,4 +4,6 @@ ENV container=docker
RUN yum install -y epel-release && \
yum install -y rpmdevtools yum-utils fakeroot && \
yum clean all
\ No newline at end of file
yum clean all
CMD ["/bin/bash/bash"]
\ No newline at end of file
#! /bin/bash
# Exit on any individual command failure.
set -e
# Pretty colors.
red='\033[0;31m'
green='\033[0;32m'
neutral='\033[0m'
# Print CentOS release
printf ${green}"$(cat /etc/redhat-release)"${neutral}"\n"
# Check packeges installed
pkgs_list=("rpmdevtools" "yum-utils" "fakeroot")
for i in ${pkgs_list[@]}
do
if [[ $(rpm -q $i --quiet) ]]; then
printf ${red}"Package $i is not installed"${neutral}"\n"
fi
done
printf ${green}"All Required Packages are installed"${neutral}"\n"
\ No newline at end of file
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