Commit fd3e67a6 authored by Daniele Venzano's avatar Daniele Venzano

Mirror the repository every time the CI build is successful

parent 1dc4a825
......@@ -48,20 +48,6 @@ docs-test:
- doc8 docs/
- sh ./build_docs.sh
SonarQube:
stage: static-test
image: zoerepo/sonar-scanner
variables:
SONAR_PROJECT_KEY: "zoe.devel"
SONAR_BRANCH: "$CI_BUILD_REF_NAME"
SONAR_PROJECT_NAME: "$CI_PROJECT_NAME"
SONAR_PROJECT_VERSION: "$CI_BUILD_REF"
SONARQUBE_SERVER_URL: "$SONARQUBE_SERVER_URL"
script:
- /usr/bin/sonar-scanner-run.sh
only:
- devel/master
api-test:
stage: integration-test
services:
......@@ -105,6 +91,18 @@ images:
only:
- master
mirror-github:
stage: deploy
image: python:3.4
before_script:
- which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- ssh -A ubuntu@${STAGING_IP} /home/ubuntu/mirror-github.sh
docs:
stage: deploy
image: ${DOCKER_REGISTRY}/ci/${ZOE_TEST_IMAGE}
......
FROM java:alpine
ENV SONAR_SCANNER_VERSION 2.8
RUN apk add --no-cache wget && \
wget https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-${SONAR_SCANNER_VERSION}.zip && \
unzip sonar-scanner-${SONAR_SCANNER_VERSION} && \
cd /usr/bin && ln -s /sonar-scanner-${SONAR_SCANNER_VERSION}/bin/sonar-scanner sonar-scanner && \
apk del wget
RUN apk add --no-cache python3 curl && rm -f /var/cache/apk/*
RUN curl https://bootstrap.pypa.io/get-pip.py | python3
RUN pip install pylint
COPY sonar-scanner-run.sh /usr/bin
RUN chmod 755 /usr/bin/sonar-scanner-run.sh
#!/bin/sh
if [ -z "${SONAR_PROJECT_KEY}" ]; then
echo "Undefined \"projectKey\"" && exit 1
else
COMMAND="sonar-scanner -Dsonar.sourceEncoding=UTF-8 -Dsonar.sources=. -Dsonar.exclusions=\"zoe_api/web/static/**\" -Dsonar.host.url=\"$SONARQUBE_SERVER_URL\" -Dsonar.login=\"$SONARQUBE_USER\" -Dsonar.password=\"$SONARQUBE_PASSWORD\" -Dsonar.projectKey=\"${SONAR_PROJECT_KEY}\""
if [ ! -z "${SONAR_PROJECT_VERSION}" ]; then
COMMAND="$COMMAND -Dsonar.projectVersion=\"${SONAR_PROJECT_VERSION}\""
fi
if [ ! -z "${SONAR_PROJECT_NAME}" ]; then
COMMAND="$COMMAND -Dsonar.projectName=\"${SONAR_PROJECT_NAME}\""
fi
if [ ! -z ${CI_BUILD_REF} ]; then
COMMAND="$COMMAND -Dsonar.gitlab.commit_sha=\"${CI_BUILD_REF}\""
fi
if [ ! -z ${CI_BUILD_REF_NAME} ]; then
COMMAND="$COMMAND -Dsonar.gitlab.ref_name=\"${CI_BUILD_REF_NAME}\""
fi
if [ ! -z ${SONAR_BRANCH} ]; then
COMMAND="$COMMAND -Dsonar.branch=\"${SONAR_BRANCH}\""
fi
eval ${COMMAND}
fi
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