Commit 4774c2bd authored by Alberto Debiasi's avatar Alberto Debiasi
Browse files

Update .gitlab-ci.yml

parent a800ea5e
image: maven:3.3.9-jdk-8
#cache:
# paths:
# - $HOME/.m2/repository
variables:
M2_REPO: "/tmp/.m2"
......@@ -14,58 +8,166 @@ variables:
# when running from the command line.
# `installAtEnd` and `deployAtEnd`are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true -Dmaven.repo.local=$M2_REPO/repository -gs $M2_REPO/settings.xml -Dhttps.protocols=TLSv1.2"
SKIP_TESTS_OPT: ""
# SKIP_DEPENDENCIES: "false"
AUTO_DEPLOY_TO_PRODUCTION: "false"
UPDATE_SITE_ROOT: "/data/www/es-static.fbk.eu/html/tools"
DEPLOY_TMP_DIR : "/tmp/gitlab_ci_deploy"
UPDATE_SITE_DIR: "${UPDATE_SITE_ROOT}/eclipse/${UPDATE_SITE_DIR_ECLIPSE_VERSION_DIR}/${UPDATE_SITE_DIR_NAME}"
UPDATE_SITE_DIR_NEW: "${UPDATE_SITE_ROOT}/eclipse/${UPDATE_SITE_DIR_ECLIPSE_VERSION_DIR}/${UPDATE_SITE_DIR_NAME}_new"
UPDATE_SITE_DIR_PREV: "${UPDATE_SITE_ROOT}/eclipse/${UPDATE_SITE_DIR_ECLIPSE_VERSION_DIR}/${UPDATE_SITE_DIR_NAME}_prev"
UPDATE_SITE_URL: "esuser@es-services-website.fbk.eu"
stages:
- test
- deploy
#- documentation
#- release
maven_build_and_test:
stage: test
environment: staging
variables:
script:
# - rm -rf $M2_REPO
# - mkdir $M2_REPO
- cp settings.xml $M2_REPO
- "export DISPLAY=:0.0; mvn $MAVEN_CLI_OPTS -P Neon,Java8,DevelopmentUpdateSite clean deploy"
only:
- master
.deploy_to_production_update_site: &deploy_to_production_update_site
dependencies:
- maven_build_and_test
variables:
GIT_STRATEGY: none
stage: deploy
environment: staging
script:
- echo "Deploy to production update site"
- cd "eu.fbk.tools.aida.sde.repository"
- "export DISPLAY=:0.0; mvn $MAVEN_CLI_OPTS -P Neon,Java8,ProductionUpdateSite deploy"
- cd ".."
- cd "eu.fbk.tools.sde.repository.neon"
- "export DISPLAY=:0.0; mvn $MAVEN_CLI_OPTS -P Neon,Java8,ProductionUpdateSite deploy"
only:
refs:
- master
automatic_deploy_to_production_update_site:
<< : *deploy_to_production_update_site
only:
variables:
- $AUTO_DEPLOY_TO_PRODUCTION == "true"
manual_to_production_update_site:
<< : *deploy_to_production_update_site
when: manual
only:
variables:
- $AUTO_DEPLOY_TO_PRODUCTION == "false"
- build_test_and_deploy
- deploy_to_production
# this is invoked before every job
before_script:
## Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
## We're using tr to fix line endings which makes ed25519 keys work
## without extra base64 encoding.
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
##
## used to upload the update sites on the server
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' >> ~/.ssh/id_rsa_website
- chmod 0600 ~/.ssh/id_rsa_website
- ssh-add ~/.ssh/id_rsa_website
- ssh-keygen -y -e -f ~/.ssh/id_rsa_website
- echo "$SSH_CONFIG" | tr -d '\r' >> ~/.ssh/config
- chmod 0644 ~/.ssh/config
- ssh-keyscan -t rsa jump.fbk.eu >> /root/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- cat ~/.ssh/known_hosts
# prepare the .m2 repository
- rm -rf $M2_REPO
- mkdir $M2_REPO
- cp settings.xml $M2_REPO
# some tests call the python executable
- ln /usr/bin/python2 /usr/bin/python
.build_test_and_deploy:
tags:
- eclipse
variables:
GIT_STRATEGY: clone
# only:
# - master
script:
- echo "Building and testing"
- echo $UPDATE_SITE_URL
- "export DISPLAY=:0.0; mvn $MAVEN_CLI_OPTS -P$PROFILE $SKIP_TESTS_OPT clean install"
- echo "Deploy to update site"
- echo "- Preparing the temporary update site dir"
- ssh -o StrictHostKeyChecking=no $UPDATE_SITE_URL "mkdir -p $UPDATE_SITE_DIR_NEW ; rm -rf $UPDATE_SITE_DIR_NEW/*"
#- ssh -o StrictHostKeyChecking=no $UPDATE_SITE_URL "rm -rf $UPDATE_SITE_DIR_NEW/*"
- echo "- Uploading the update site to the temporary update site dir"
- scp -r ${TARGET_REPOSITORY_DIR} ${UPDATE_SITE_URL}:$UPDATE_SITE_DIR_NEW
- echo "- Discarding the previous update site"
- ssh -o StrictHostKeyChecking=no $UPDATE_SITE_URL "mkdir -p $DEPLOY_TMP_DIR"
- ssh -o StrictHostKeyChecking=no $UPDATE_SITE_URL "mkdir -p $DEPLOY_TMP_DIR/$UPDATE_SITE_DIR_ECLIPSE_VERSION_DIR"
- ssh -o StrictHostKeyChecking=no $UPDATE_SITE_URL "rm -rf $DEPLOY_TMP_DIR/$UPDATE_SITE_DIR_ECLIPSE_VERSION_DIR"
- ssh -o StrictHostKeyChecking=no $UPDATE_SITE_URL "mkdir -p $UPDATE_SITE_DIR_PREV"
- ssh -o StrictHostKeyChecking=no $UPDATE_SITE_URL "mv -f $UPDATE_SITE_DIR_PREV $DEPLOY_TMP_DIR/$UPDATE_SITE_DIR_ECLIPSE_VERSION_DIR"
- echo "- Moving current update site to previous update site"
- ssh -o StrictHostKeyChecking=no $UPDATE_SITE_URL "mkdir -p $UPDATE_SITE_DIR ; mv -f $UPDATE_SITE_DIR /$UPDATE_SITE_DIR_PREV"
#- ssh -v -o StrictHostKeyChecking=no $UPDATE_SITE_URL "mv -f $UPDATE_SITE_DIR /$UPDATE_SITE_DIR_PREV"
- echo "- Putting on line the new update site"
- ssh -o StrictHostKeyChecking=no $UPDATE_SITE_URL "mv -f $UPDATE_SITE_DIR_NEW $UPDATE_SITE_DIR"
Neon:B_and_T:
extends:
.build_test_and_deploy
image: braghieri/eclipse:Java8-Python2
stage: build_test_and_deploy
variables:
PROFILE: "Java8,Neon"
UPDATE_SITE_DIR_ECLIPSE_VERSION_DIR: "neon"
UPDATE_SITE_DIR_NAME: "sde_devel"
TARGET_REPOSITORY_DIR : $CI_PROJECT_DIR/eu.fbk.tools.sde.repository.neon/target/repository/*
# only:
# - master
2020-06:B_and_T:
extends:
.build_test_and_deploy
image: braghieri/eclipse:Java11-Python2
stage: build_test_and_deploy
variables:
PROFILE: "Java11,2020-06"
UPDATE_SITE_DIR_ECLIPSE_VERSION_DIR: "2020-06"
UPDATE_SITE_DIR_NAME: "sde_devel"
TARGET_REPOSITORY_DIR : $CI_PROJECT_DIR/eu.fbk.tools.sde.repository.2020-06/target/repository/*
# only:
# - master
2021-03:B_and_T:
extends:
.build_test_and_deploy
image: braghieri/eclipse:Java11-Python2
stage: build_test_and_deploy
variables:
PROFILE: "Java11,2021-03"
UPDATE_SITE_DIR_ECLIPSE_VERSION_DIR: "2021-03"
UPDATE_SITE_DIR_NAME: "sde_devel"
TARGET_REPOSITORY_DIR : $CI_PROJECT_DIR/eu.fbk.tools.sde.repository.2021-03/target/repository/*
# only:
# - master
Neon:to_production_update_site:
extends:
.build_test_and_deploy
image: braghieri/eclipse:Java8-Python2
stage: deploy_to_production
needs:
- Neon:B_and_T
when: manual
variables:
PROFILE: "Java8,Neon"
SKIP_TESTS_OPT: "-DskipTests"
UPDATE_SITE_DIR_ECLIPSE_VERSION_DIR: "neon"
UPDATE_SITE_DIR_NAME: "sde"
TARGET_REPOSITORY_DIR : $CI_PROJECT_DIR/eu.fbk.tools.sde.repository.neon/target/repository/*
2020-06:to_production_update_site:
extends:
.build_test_and_deploy
image: braghieri/eclipse:Java11-Python2
stage: deploy_to_production
needs:
- 2020-06:B_and_T
when: manual
variables:
PROFILE: "Java11,2020-06"
SKIP_TESTS_OPT: "-DskipTests"
UPDATE_SITE_DIR_ECLIPSE_VERSION_DIR: "2020-06"
UPDATE_SITE_DIR_NAME: "sde"
TARGET_REPOSITORY_DIR : $CI_PROJECT_DIR/eu.fbk.tools.sde.repository.2020-06/target/repository/*
2021-03:to_production_update_site:
extends:
.build_test_and_deploy
image: braghieri/eclipse:Java11-Python2
stage: deploy_to_production
needs:
- 2021-03:B_and_T
when: manual
variables:
PROFILE: "Java11,2021-03"
SKIP_TESTS_OPT: "-DskipTests"
UPDATE_SITE_DIR_ECLIPSE_VERSION_DIR: "2021-03"
UPDATE_SITE_DIR_NAME: "sde"
TARGET_REPOSITORY_DIR : $CI_PROJECT_DIR/eu.fbk.tools.sde.repository.2021-03/target/repository/*
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