...
 
Commits (2)
......@@ -10,28 +10,39 @@ services:
stages:
- build
- test
- deploy
variables:
TEST_IMAGE: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/$CI_COMMIT_REF_NAME:test
DEPLOY_IMAGE: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/$CI_COMMIT_REF_NAME
TEST_IMAGE: ${CI_REGISTRY}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/${CI_COMMIT_REF_NAME}:test
DEPLOY_IMAGE: ${CI_REGISTRY}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/${CI_COMMIT_REF_NAME}
build:
stage: build
script:
- docker build -f Dockerfile -t $TEST_IMAGE --build-arg CI_REGISTRY=$CI_REGISTRY --no-cache=true .
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker push $TEST_IMAGE
- docker build -f Dockerfile -t ${TEST_IMAGE} --build-arg CI_REGISTRY=${CI_REGISTRY} --no-cache=true .
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
- docker push ${TEST_IMAGE}
test_os:
stage: test
script:
- docker run --rm ${TEST_IMAGE} bash -c "apt-get update && apt-get -y upgrade"
test_mvn:
stage: test
script:
- docker run --rm ${TEST_IMAGE} bash -c "mvn -v"
deploy:
stage: deploy
script:
- docker pull $TEST_IMAGE
- docker tag $TEST_IMAGE $DEPLOY_IMAGE:latest
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker push $DEPLOY_IMAGE:latest
- docker tag $TEST_IMAGE $DEPLOY_IMAGE:$(date +%Y%m%d)
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker push $DEPLOY_IMAGE:$(date +%Y%m%d)
- docker pull ${TEST_IMAGE}
- docker tag ${TEST_IMAGE} ${DEPLOY_IMAGE}:latest
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
- docker push ${DEPLOY_IMAGE}:latest
- docker tag ${TEST_IMAGE} ${DEPLOY_IMAGE}:$(date +%Y%m%d)
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
- docker push ${DEPLOY_IMAGE}:$(date +%Y%m%d)
only:
- master
ARG CI_REGISTRY
FROM ${CI_REGISTRY}/sw4j-net/jdk11/master:latest
ARG VERSION=3.5.4
ARG VERSION=3.6.0
ARG BASE_URL=https://www-us.apache.org/dist
ARG SHA=ce50b1c91364cb77efe3776f756a6d92b76d9038b0a0782f7d53acf1e997a14d
ARG SHA=fae9c12b570c3ba18116a4e26ea524b29f7279c17cbaadc3326ca72927368924d9131d11b9e851b8dc9162228b6fdea955446be41207a5cfc61283dd8a561d2f
RUN apt-get update && \
apt-get -y upgrade && \
apt-get -y install curl && \
mkdir -p /usr/share/apache-maven && \
curl -sSL ${BASE_URL}/maven/maven-3/${VERSION}/binaries/apache-maven-${VERSION}-bin.tar.gz -o apache-maven-bin.tar.gz && \
echo "${SHA} apache-maven-bin.tar.gz" | sha256sum -c && \
echo "${SHA} apache-maven-bin.tar.gz" | sha512sum -c && \
tar xzCf /usr/share/apache-maven apache-maven-bin.tar.gz --strip-components=1 && \
ln -s /usr/share/apache-maven/bin/mvn /usr/bin && \
rm -f apache-maven-bin.tar.gz